Path: news.mathworks.com!not-for-mail
From: Brian Arnold <Brian.Arnold@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Mex error in 64-bit 2008a Mac OS X beta
Date: Thu, 24 Jul 2008 09:17:08 -0400
Organization: The MathWorks, Inc.
Lines: 122
Message-ID: <488880D4.9090606@mathworks.com>
References: <g67985$4pk$1@fred.mathworks.com>
NNTP-Posting-Host: dev02maci.dhcp.mathworks.com
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: fred.mathworks.com 1216905429 7143 172.31.44.103 (24 Jul 2008 13:17:09 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 24 Jul 2008 13:17:09 +0000 (UTC)
To: Sridhar Mahadevan <mahadeva@cs.umass.edu>
User-Agent: Thunderbird 2.0.0.14 (Macintosh/20080421)
In-Reply-To: <g67985$4pk$1@fred.mathworks.com>
Xref: news.mathworks.com comp.soft-sys.matlab:481517


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.
> 
>