|
Hi Sridhar,
Try the following to diagnose the root cause.
Run the first g++ command, with ! before the command to escape out to
the shell and run it, then run !nm FastGSOGP.o.
The output of nm should contain a line with "T _mexFunction". If it
does not show up, or if it shows up with lots of characters before and
after the name (for example, __Z11mexFunctionsPP11mxArray_tagsPPKS_),
then something may be wrong with how it is being declared in the source
file FastGSOGP.cpp.
The declaration in your source file should match the parameter types
exactly, like this:
void mexFunction( int nlhs, mxArray *plhs[],
int nrhs, const mxArray *prhs[] )
The integer arguments must be the intrinsic "int" type (without
qualifiers), for this signature to work on all platforms. Use of short
or long integer, or other derived types, will cause the signature to
fail to be an exact match for certain compilers.
Brian
Sridhar Mahadevan wrote:
> I'm having trouble mex'ing some C++ code, which I have been able
> to compile successfully both on 64-bit Windows, Linux, as well as 32-bit Mac
> MATLAB versions. The problem is in the link loader (_mexFunction is
> undefined).
>
> The output of mex -v -g is given below. Any help would be much
> appreciated!
>
> Thanks.
>
> - Sridhar
>
> mex -g -v -largeArrayDims FastGSOGP.cpp
> -> mexopts.sh sourced from directory (DIR = $MATLAB/bin)
> FILE = /Applications/MATLAB_R2008a/bin/mexopts.sh
> -----------------------------------------------------------
> -----
> -> MATLAB = /Applications/MATLAB_R2008a
> -> CC = gcc-4.0
> -> CC flags:
> CFLAGS = -fno-common -no-cpp-precomp -arch x86_64 -
> isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5 -
> fexceptions
> CDEBUGFLAGS = -g
> COPTIMFLAGS = -O2 -DNDEBUG
> CLIBS = -L/Applications/MATLAB_R2008a/bin/maci64 -lmx -
> lmex -lmat -lstdc++
> arguments =
> -> CXX = g++-4.0
> -> CXX flags:
> CXXFLAGS = -fno-common -no-cpp-precomp -fexceptions -
> arch x86_64 -isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-
> version-min=10.5
> CXXDEBUGFLAGS = -g
> CXXOPTIMFLAGS = -O2 -DNDEBUG
> CXXLIBS = -L/Applications/MATLAB_R2008a/bin/maci64 -lmx -
> lmex -lmat -lstdc++
> arguments =
> -> FC = gfortran
> -> FC flags:
> FFLAGS = -m64
> FDEBUGFLAGS = -g
> FOPTIMFLAGS = -O
> FLIBS = -L/Applications/MATLAB_R2008a/bin/maci64 -lmx -
> lmex -lmat -L -lgfortran -L -lgfortranbegin
> arguments =
> -> LD = gcc-4.0
> -> Link flags:
> LDFLAGS = -Wl,-twolevel_namespace -undefined error -arch
> x86_64 -Wl,-syslibroot,/Developer/SDKs/MacOSX10.5.sdk -mmacosx-
> version-min=10.5 -bundle -Wl,-
> exported_symbols_list,/Applications/MATLAB_R2008a/extern/lib/maci64/me
> xFunction.map
> LDDEBUGFLAGS = -g
> LDOPTIMFLAGS = -O
> LDEXTENSION = .mexmaci64
> arguments =
> -> LDCXX =
> -> Link flags:
> LDCXXFLAGS =
> LDCXXDEBUGFLAGS =
> LDCXXOPTIMFLAGS =
> LDCXXEXTENSION =
> arguments =
> -----------------------------------------------------------
> -----
>
> -> g++-4.0 -c -I/Applications/MATLAB_R2008a/extern/include -
> DMATLAB_MEX_FILE -fno-common -no-cpp-precomp -fexceptions -arch
> x86_64 -isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-
> min=10.5 -g "FastGSOGP.cpp"
>
> -> gcc-4.0 -c -I/Applications/MATLAB_R2008a/extern/include -
> DMATLAB_MEX_FILE -fno-common -no-cpp-precomp -arch x86_64 -
> isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5 -
> fexceptions -g "/Applications/MATLAB_R2008a/extern/src/mexversion.c"
>
> -> gcc-4.0 -g -Wl,-twolevel_namespace -undefined error -arch x86_64 -
> Wl,-syslibroot,/Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-
> min=10.5 -bundle -Wl,-
> exported_symbols_list,/Applications/MATLAB_R2008a/extern/lib/maci64/me
> xFunction.map -o "FastGSOGP.mexmaci64" FastGSOGP.o mexversion.o -
> L/Applications/MATLAB_R2008a/bin/maci64 -lmx -lmex -lmat -lstdc++
>
> Undefined symbols:
> "_mexFunction", referenced from:
> -exported_symbols_list command line option
> ld: symbol(s) not found
> collect2: ld returned 1 exit status
>
> mex: link of ' "FastGSOGP.mexmaci64"' failed.
>
>
|