I am trying to compile a C file using mex (MATLAB 2012b on MacOSX Lion). My project consists of three files:
- The Header File where the main functionality is defined, smdvquad.h
- The C implementation of smdvquad.h, namely smdvquad.c which #includes smdvquad.h and
- A C file containing the “mexFunction”, namely mxsmdvquad.c which #includes smdvquad.h
The whole project compiles absolutely fine on Netbeans, but when I try to compile it using mex on MATLAB, i.e. using the command:
mex -largeArrayDims mxsmdvquad.c
the following error is thrown:
>> mex -largeArrayDims mxsmdvquad.c
Undefined symbols for architecture x86_64:
"_smdv_quad", referenced from:
_mexFunction in mxsmdvquad.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
mex: link of ' "mxsmdvquad.mexmaci64"' failed.
Error using mex (line 206)
Unable to complete successfully.
I have also tried specifying the working directory using the -I mex-argument, i.e.
mex -largeArrayDims -I/path/to/my/project/ mxsmdvquad.c
but in vain!
I would expect that one of the following would work:
Maybe you also need to compile
smdvquad.c?or if you already compiled smdvquad, you maybe need to link it:
or if it’s in a different directory, you need to add the directory to the linker with
-L: