Compiling MEX version of C file

13 views (last 30 days)
Jose Luis Licon
Jose Luis Licon on 4 Nov 2014
Commented: Geoff Hayes on 6 Nov 2014
I'm running Matlab R2014b on OSX 10.8.5 (I have Xcode 5.0.2 installed, as well as GCC 4.2.1). I'm trying to install the TPROD package (available here ), and the process involves compiling certain MEX files. Calling `tprod()` within Matlab should run the compilation process, but I get the following message:
Error using tprod (line 149)
unable to compile MEX version of '~/src/MATLAB/tprod/tprod', please make sure your
MEX compiler is set up correctly (try 'mex -setup').
Running `mex -setup` produces the following:
MEX configured to use 'Xcode with Clang' for C language compilation.
Warning: The MATLAB C and Fortran API has changed to support MATLAB
variables with more than 2^32-1 elements. In the near future
you will be required to update your code to utilize the
new API. You can find more information about this at:
http://www.mathworks.com/help/matlab/matlab_external/upgrading-mex-files-to-use-64-bit-api.html.
To choose a different language, select one from the following:
mex -setup C++
mex -setup FORTRAN
C is indeed the language required by TPROD. This is the first time I have to compile MEX files, so I have no idea of what might be the problem. Any hints will be appreciated!
[1]: http://www.mathworks.com/matlabcentral/fileexchange/16275-tprod-arbitary-tensor-products-between-n-d-arrays
  1 Comment
Geoff Hayes
Geoff Hayes on 6 Nov 2014
If I try the above, same OS but R2014a, I observe the same error. Though the message is misleading because there is nothing wrong with your setup. If you take the line of code that is building the MEX function
mex('ddtprod.c','dstprod.c','sdtprod.c','sstprod.c','tprod_util.c','tprod_mex.c','mxInfo.c','mxInfo_mex.c','-O','-output',mfilename);
and run this in the Command Window, you will see the following error
Error using mex
Undefined symbols for architecture x86_64:
"_b22XYmacc_ddcxcy", referenced from:
_b22XY_tprod_ddcxcy in ddtprod.o
"_b22XYmacc_ddcxry", referenced from:
_b22XY_tprod_ddcxry in ddtprod.o
"_b22XYmacc_ddrxcy", referenced from:
_b22XY_tprod_ddrxcy in ddtprod.o
"_b22XYmacc_dscxcy", referenced from:
_b22XY_tprod_dscxcy in dstprod.o
"_b22XYmacc_dscxry", referenced from:
_b22XY_tprod_dscxry in dstprod.o
"_b22XYmacc_dsrxcy", referenced from:
_b22XY_tprod_dsrxcy in dstprod.o
"_b22XYmacc_dsrxry", referenced from:
_b22XY_tprod_dsrxry in dstprod.o
"_b22XYmacc_sdcxcy", referenced from:
_b22XY_tprod_sdcxcy in sdtprod.o
"_b22XYmacc_sdcxry", referenced from:
_b22XY_tprod_sdcxry in sdtprod.o
"_b22XYmacc_sdrxcy", referenced from:
_b22XY_tprod_sdrxcy in sdtprod.o
etc.
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see
invocation)
The above is just a sample of the errors (there are probably 30+ undefined symbols). It seems that functions are "built" at compile time (see tprod.def for details) but it isn't clear to me how this occurs.
If I try to run the same code (with same version of MATLAB) on a 32-bit Windows (using MS SDK 7.1 as C compiler) it works fine. Perhaps you can try the same on a PC.

Sign in to comment.

Answers (0)

Categories

Find more on Troubleshooting in MATLAB Compiler SDK in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!