MATLAB codegen gives a build error status code 2 (gmake access denied)

I am trying to compile a MATLAB function into a "MEX" file to improve speed. I have successfully done this conversion via the "codegen" function in MATLAB on my work computer, using MATLAB ver. R2012a (64 bit) on a Windows 7 Enterprise 64-bit PC. I have installed and chosen "Microsoft Software Development Kit (SDK) 7.1" as the default compiler in MATLAB.
With the exact same setup as above on my personal laptop (same MATLAB version with the same license, 64 bit, same compiler) and Windows 7 Home Premium 64 bit, I keep getting a build error with the same piece of code. When I looked into the Target build log, it says that the error was "gmake: Access is Denied", as you can see below.
1 cl /c /GR /W3 /EHs /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE /nologo /MD -DMX_COMPAT_32 /O2 /Oy- /DNDEBUG /fp:strict /I "C:\PROGRA~1\MATLAB\R2012a\extern\include" /I "C:\PROGRA~1\MATLAB\R2012a\simulink\include" /I "C:\PROGRA~1\MATLAB\R2012a\toolbox\shared\simtargets" /I "C:\PROGRA~1\MATLAB\R2012a\rtw\ext_mode\common" /I "C:\PROGRA~1\MATLAB\R2012a\rtw\c\src\ext_mode\common" /I "C:\Users\Litetaker\Desktop\MATLAB\LTE_Link_Level_1.7_r1089\codegen\mex\func_mcma_mult_miso2" "func_mcma_mult_miso2_mexutil.c"
2 func_mcma_mult_miso2_mexutil.c
3 cl /c /GR /W3 /EHs /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE /nologo /MD -DMX_COMPAT_32 /O2 /Oy- /DNDEBUG /fp:strict /I "C:\PROGRA~1\MATLAB\R2012a\extern\include" /I "C:\PROGRA~1\MATLAB\R2012a\simulink\include" /I "C:\PROGRA~1\MATLAB\R2012a\toolbox\shared\simtargets" /I "C:\PROGRA~1\MATLAB\R2012a\rtw\ext_mode\common" /I "C:\PROGRA~1\MATLAB\R2012a\rtw\c\src\ext_mode\common" /I "C:\Users\Litetaker\Desktop\MATLAB\LTE_Link_Level_1.7_r1089\codegen\mex\func_mcma_mult_miso2" "func_mcma_mult_miso2_data.c"
4 func_mcma_mult_miso2_data.c
5 gmake: *** Access is denied.
6 . Stop.
Can someone help me fix this error? I don't know what I am doing wrong. Note that this gmake executable is in the MATLAB install directory at: C:\Program Files\MATLAB\R2012a\bin\win64\gmake and when I call it on its own from the command line, it seems to work fine. But through MATLAB, it seems to fail.

5 Comments

I would start by checking the permissions/security on the directory containing func_mcma_mult_miso2_data.c and other files which are being built by gmake.
Can you try to change your output directory with:
codegen ... -d C:\some\new\directory\with\read\write\access
and see if that succeeds?
So I tried to do the following: I ran the generated Windows Batch files (.bat) that codegen creates in a directory along with the C source code for my MATLAB function. Ideally if this .bat file runs without any problems, I should generate the corresponding MEX file at the end. The last line in the .bat file calls the "gmake.exe" executable from the MATLAB installation directory. It seems to run ok, but after a while upon a successive call to "gmake" with input as one of the other .c files, it errors out and gives the "Access is Denied" error. When I re-ran the .bat file, "gmake" seems to error out at a different .c input file.
Here is a pastebin for the error at the terminal: http://pastebin.com/WWT4R5Ye
I hope I can get this sorted out as it is quite frustrating. Thanks for the help in advance.
Hi Abhijit, can you try three things: - Disable antivirus protection one your computer - Open a command prompt window with administrator rights, and run the codegen-created batch file from there - If the above does not help, use codegen again, but use "-d" flag as Ryan suggested above, giving it some destination folder that you definitely have read and write access to?
This "access denied" error seem to be related to your computer configuration, somehow the destination folder (where the C compiler places .obj files) is either write-protected, or unavailable.
As I mentioned in a comment for an answer below, I tried the -d flag to set a different output directory and it seems to have corrected the issue. I am not 100% that this was the solution, but I suppose it helped. I'll check one last time with the default directory and see if it just happened to fix itself!
Hi Abhijit, I just noticed that the desitnation folder (where your MATLAB and C files are) is in your Desktop folder (C:\Users\Litetaker\Desktop\MATLAB..). I just learned that Windows has some tricky file permission rules for files under "Desktop" - not all software is allowed to create files there. I don't know the details, but perhaps you can try reproducing the issue outside of the desktop folder (e.g. create c:\Work\MATLAB\, copy all files there, and run codegen command from there). I wonder if this would help. -- Denis.

Sign in to comment.

Answers (1)

The access that is being denied is potentially to one of the output files.
If you had a "stuck" gmake and then ran gmake again, you could encounter this.
If you had one of the output files open and then ran gmake you could encounter this.
If gmake is working in parallel (building multiple files simultaneously) then you could potentially encounter this.

2 Comments

Thank you for your reply. I believe that I did something out of the ordinary that may have caused this problem, but I seemed to have solved it now.
So I sync my MATLAB working directory between my work PC and my home Laptop using Dropbox. I first compiled a particular function on my work PC which created a bunch of folders that contained the generated C code and other object files. I tried to compile the same function at home and used the same output folder for the C and object files, which kept causing errors. I just tried setting a different directory as the output directory and it worked without errors. I am not sure if changing the directory was really the solution or if it was because I tried it on a different instance of MATLAB, or rebooting my computer etc.
In any case, thanks for the help and I hope others may find this useful. Also hoping to not run into this mess again! :)
The created directories might not have access authorization for your account at home.

Sign in to comment.

Categories

Products

Asked:

on 23 Jul 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!