How to call Matlab user defined function on Xcode 5 using mexCallMatlab?
1 view (last 30 days)
Show older comments
Hello,
I'm really stuck in setting a Xcode 5 project to call a Matlab function. Since the engine.h calls only built in function, I can't refer to this post: http://www.mathworks.com/matlabcentral/answers/91611-how-can-i-build-an-engine-application-using-the-xcode-ide-on-mac
I actually even tried it but it didn't work. So, here I have:
-Maverick 10.9.1
-Xcode 5.0.2
and I am trying to call a dummy Matlab function that won't do anything. After creating the command line tool project on Xcode, I set up a few things:
Build Settings-> Search Paths -> Header Search Paths and add $MATLABROOT/extern/include
To find the headers ("mex.h" in particular)
And build Settings-> Search Paths -> Library Search Paths and add: $MATLABROOT/bin/maci64 and $MATLABROOT/sys/os/maci64
Also, I added the following variables to the Unix environment:
$MATLABROOT/bin/maci64:
$MATLABROOT/sys/os/maci64:
/System/Library/Frameworks/JavaVM.framework/JavaVM:
/System/Library/Frameworks/JavaVM.framework/Libraries
And finally set up the architecture to Universal (32/64 bit Intel)
But still getting the following error:
Undefined symbols for architecture x86_64: "_mexCallMATLAB", referenced from: _main in main.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
Did anyone encounter the same problem and solved it? or have any leads as to why it is not working? Thank you
Update: Just tried the example mexcallmatlab.c and got the same error. I added manually the libraries libmx.dylib and libeng.dylib (which should be found automatically since I put their path in the Library search paths). The errors are now:
Undefined symbols for architecture x86_64: "_main", referenced from: implicit entry/start for main executable "_mexCallMATLAB", referenced from: _mexFunction in main.o "_mexErrMsgIdAndTxt", referenced from: _mexFunction in main.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
2 Comments
Stefano
on 19 Aug 2014
I have the same problem... cannot run the mexcallmatlab.c example on Mac OS 10.9. Any updates here?
Geoff Hayes
on 19 Aug 2014
Stefano - it may be worthwhile to create a new question and outline exactly what you are doing with mexcallmatlab.c and describe in detail the errors that you observe. In the Command Window of MATLAB, I can run
mex mexcallmatlab.c
and then
mexcallmatlab
to get the expected output. This program may not be designed to run through Xcode without some modification and the creation of the "engine". Is that what you are doing?
Note that I am running MATLAB R2014a on OS X 10.8.5.
Answers (0)
See Also
Categories
Find more on Write C Functions Callable from MATLAB (MEX Files) 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!