Trouble linking libraries when building a C MEX file in Xcode

1 view (last 30 days)
I am trying to build a MATLAB MEX file in Xcode (version 4.6.3) for debugging purposes. I was already able to successfully compile the program in MATLAB (R2013a) using this command:
>> mex src/main.c src/binomial.c src/gaussian1.c src/gaussianU.c src/poisson.c -Iinclude -I/usr/local/include -L/usr/local/lib -lmpfr -output cpdetect_c
When I try to build it in Xcode, the program compiles successfully, but the build fails at the linking stage with errors like this:
Undefined symbols for architecture x86_64:
"_mexErrMsgIdAndTxt", referenced from:
_mexFunction in main.o
"_mexPrintf", referenced from:
_find_gaussian1_change_point in gaussian1.o
_cpdetect in main.o
_find_poisson_change_point in poisson.o
"_mpfr_add", referenced from:
_find_gaussian1_change_point in gaussian1.o
_find_gaussianU_change_point in gaussianU.o
_find_poisson_change_point in poisson.o
"_mxCreateDoubleMatrix_730", referenced from:
_mexFunction in main.o
As described in this post, I have the following settings in Xcode:
>> Other Linker Flags: -lmx -lmex -lmat -lmpfr
>> Header Search Paths: $(MATLABROOT)/extern/include
/Users/myName/Documents/MATLAB/SingleMolecule/Current_Version/cpdetect_c_mex/include
/usr/local/include
>> Library Search Paths: $(MATLABROOT)/bin/maci64 /usr/local/lib
but this is apparently not sufficient for successful linking. What am I missing? Thanks for any suggestions!
  1 Comment
Kaustubha Govind
Kaustubha Govind on 27 Mar 2014
I wonder if you are building a 64-bit MEX in Xcode against 32-bit MATLAB libraries, or vice versa.

Sign in to comment.

Answers (0)

Categories

Find more on Write C Functions Callable from MATLAB (MEX Files) 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!