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

6 views (last 30 days)
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
Abhijit Kiran
Abhijit Kiran on 31 Jul 2013
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!
Denis Gurchenkov
Denis Gurchenkov on 31 Jul 2013
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)

Walter Roberson
Walter Roberson on 30 Jul 2013
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
Abhijit Kiran
Abhijit Kiran on 30 Jul 2013
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! :)
Walter Roberson
Walter Roberson on 30 Jul 2013
The created directories might not have access authorization for your account at home.

Sign in to comment.

Categories

Find more on Introduction to Installation and Licensing in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!