Thread Subject: Compiling RT_invcdf.c file with mex on MacOS X

Subject: Compiling RT_invcdf.c file with mex on MacOS X

From: Nicolas

Date: 7 Feb, 2012 13:26:10

Message: 1 of 3

I am running MATLAB 2011b on MacOS 10.7.2. I need to use the RT_invcdf.c fonction. When compiling it using mex command, I got the following error:

$/Applications/MATLAB_R2011b.app/bin/mex -v /Users/Nicolas/src/RT_invcdf.c
-> mexopts.sh sourced from directory (DIR = $PREF_DIR)
   FILE = /Users/Nicolas/.matlab/R2011b/mexopts.sh
----------------------------------------------------------------
-> MATLAB = /Applications/MATLAB_R2011b.app
-> CC = gcc-4.2
-> CC flags:
         CFLAGS = -fno-common -no-cpp-precomp -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.5 -fexceptions
         CDEBUGFLAGS = -g
         COPTIMFLAGS = -O2 -DNDEBUG
         CLIBS = -L/Applications/MATLAB_R2011b.app/bin/maci64 -lmx -lmex -lmat -lstdc++
         arguments = -DMX_COMPAT_32
-> CXX = g++-4.2
-> CXX flags:
         CXXFLAGS = -fno-common -no-cpp-precomp -fexceptions -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.5
         CXXDEBUGFLAGS = -g
         CXXOPTIMFLAGS = -O2 -DNDEBUG
         CXXLIBS = -L/Applications/MATLAB_R2011b.app/bin/maci64 -lmx -lmex -lmat -lstdc++
         arguments = -DMX_COMPAT_32
-> FC = gfortran
-> FC flags:
         FFLAGS = -fexceptions -fbackslash
         FDEBUGFLAGS = -g
         FOPTIMFLAGS = -O
         FLIBS = -L/Applications/MATLAB_R2011b.app/bin/maci64 -lmx -lmex -lmat -L -lgfortran -L -lgfortranbegin
         arguments = -DMX_COMPAT_32
-> LD = gcc-4.2
-> Link flags:
         LDFLAGS = -framework GLUT -Wl,-twolevel_namespace -undefined error -arch x86_64 -Wl,-syslibroot,/Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.5 -bundle -Wl,-exported_symbols_list,/Applications/MATLAB_R2011b.app/extern/lib/maci64/mexFunction.map
         LDDEBUGFLAGS = -g
         LDOPTIMFLAGS = -O
         LDEXTENSION = .mexmaci64
         arguments =
-> LDCXX =
-> Link flags:
         LDCXXFLAGS =
         LDCXXDEBUGFLAGS =
         LDCXXOPTIMFLAGS =
         LDCXXEXTENSION =
         arguments =
----------------------------------------------------------------

-> gcc-4.2 -c -I/Applications/MATLAB_R2011b.app/extern/include -I/Applications/MATLAB_R2011b.app/simulink/include -DMATLAB_MEX_FILE -fno-common -no-cpp-precomp -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.5 -fexceptions -DMX_COMPAT_32 -O2 -DNDEBUG "/Users/Nicolas/src/RT_invcdf.c"

-> gcc-4.2 -O -framework GLUT -Wl,-twolevel_namespace -undefined error -arch x86_64 -Wl,-syslibroot,/Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.5 -bundle -Wl,-exported_symbols_list,/Applications/MATLAB_R2011b.app/extern/lib/maci64/mexFunction.map -o "RT_invcdf.mexmaci64" RT_invcdf.o -L/Applications/MATLAB_R2011b.app/bin/maci64 -lmx -lmex -lmat -lstdc++

Undefined symbols for architecture x86_64:
  "_cdftnc", referenced from:
      _mexFunction in RT_invcdf.o
  "_cdft", referenced from:
      _mexFunction in RT_invcdf.o
  "_cdfpoi", referenced from:
      _mexFunction in RT_invcdf.o
  "_cdfnor", referenced from:
      _mexFunction in RT_invcdf.o
  "_cdfnbn", referenced from:
      _mexFunction in RT_invcdf.o
  "_cdfgam", referenced from:
      _mexFunction in RT_invcdf.o
  "_cdffnc", referenced from:
      _mexFunction in RT_invcdf.o
  "_cdff", referenced from:
      _mexFunction in RT_invcdf.o
  "_cdfchn", referenced from:
      _mexFunction in RT_invcdf.o
  "_cdfchi", referenced from:
      _mexFunction in RT_invcdf.o
  "_cdfbin", referenced from:
      _mexFunction in RT_invcdf.o
  "_cdfbet", referenced from:
      _mexFunction in RT_invcdf.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status

    mex: link of ' "RT_invcdf.mexmaci64"' failed.

I tried to add the -m64 for the CFLAGS, CXXFLAGS and LDFLAGS, but the error remains the same.

Subject: Compiling RT_invcdf.c file with mex on MacOS X

From: Brian Arnold

Date: 8 Feb, 2012 14:28:52

Message: 2 of 3

Hi Nicolas,

If the specified symbols cannot be found, it's because their source code
or binaries haven't been supplied with the MEX command.

When I search the Internet for RT_invcdf.c, several of the top hits link
to this snippet of code for invoking MEX to compile this file:

if strcmp(computer,'PCWIN')
   mex RT_invcdf.c ipmpar.c dcdflib.c
else %choose your own compiler flags for gnu -O2 is conservative but it
will work...
   mex RT_invcdf.c ipmpar.c dcdflib.c CFLAGS='$CFLAGS -Wall -O2'
   %aggressive compilation by Intel ICC compiler on Linux worked as well
(30% faster)
   %Pentium 3 and other IA-32 chips
   mex /opt/intel/compiler60/ia32/lib/*.a RT_invcdf.c ipmpar.c dcdflib.c
CC='icc' LD='gcc' CFLAGS='-parallel' COPTIMFLAGS='-ip -axK -O3'
end

It appears that the MEX command for RT_invcdf.c requires two other
source files, at least one of which is likely to contain the missing
symbols. So it would appear that you need to add ipmpar.c and dcdflib.c
to your MEX command. Try that.

HTH,

Brian


On 2/7/12 8:26 AM, Nicolas wrote:
> I am running MATLAB 2011b on MacOS 10.7.2. I need to use the RT_invcdf.c
> fonction. When compiling it using mex command, I got the following error:
>
> $/Applications/MATLAB_R2011b.app/bin/mex -v /Users/Nicolas/src/RT_invcdf.c
> -> mexopts.sh sourced from directory (DIR = $PREF_DIR)
> FILE = /Users/Nicolas/.matlab/R2011b/mexopts.sh
> ----------------------------------------------------------------
> -> MATLAB = /Applications/MATLAB_R2011b.app
> -> CC = gcc-4.2
> -> CC flags:
> CFLAGS = -fno-common -no-cpp-precomp -arch x86_64 -isysroot
> /Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.5 -fexceptions
> CDEBUGFLAGS = -g
> COPTIMFLAGS = -O2 -DNDEBUG
> CLIBS = -L/Applications/MATLAB_R2011b.app/bin/maci64 -lmx -lmex -lmat
> -lstdc++
> arguments = -DMX_COMPAT_32
> -> CXX = g++-4.2
> -> CXX flags:
> CXXFLAGS = -fno-common -no-cpp-precomp -fexceptions -arch x86_64
> -isysroot /Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.5
> CXXDEBUGFLAGS = -g
> CXXOPTIMFLAGS = -O2 -DNDEBUG
> CXXLIBS = -L/Applications/MATLAB_R2011b.app/bin/maci64 -lmx -lmex -lmat
> -lstdc++
> arguments = -DMX_COMPAT_32
> -> FC = gfortran
> -> FC flags:
> FFLAGS = -fexceptions -fbackslash
> FDEBUGFLAGS = -g
> FOPTIMFLAGS = -O
> FLIBS = -L/Applications/MATLAB_R2011b.app/bin/maci64 -lmx -lmex -lmat -L
> -lgfortran -L -lgfortranbegin
> arguments = -DMX_COMPAT_32
> -> LD = gcc-4.2
> -> Link flags:
> LDFLAGS = -framework GLUT -Wl,-twolevel_namespace -undefined error -arch
> x86_64 -Wl,-syslibroot,/Developer/SDKs/MacOSX10.6.sdk
> -mmacosx-version-min=10.5 -bundle
> -Wl,-exported_symbols_list,/Applications/MATLAB_R2011b.app/extern/lib/maci64/mexFunction.map
>
> LDDEBUGFLAGS = -g
> LDOPTIMFLAGS = -O
> LDEXTENSION = .mexmaci64
> arguments = -> LDCXX = -> Link flags:
> LDCXXFLAGS = LDCXXDEBUGFLAGS = LDCXXOPTIMFLAGS = LDCXXEXTENSION =
> arguments =
> ----------------------------------------------------------------
>
> -> gcc-4.2 -c -I/Applications/MATLAB_R2011b.app/extern/include
> -I/Applications/MATLAB_R2011b.app/simulink/include -DMATLAB_MEX_FILE
> -fno-common -no-cpp-precomp -arch x86_64 -isysroot
> /Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.5 -fexceptions
> -DMX_COMPAT_32 -O2 -DNDEBUG "/Users/Nicolas/src/RT_invcdf.c"
>
> -> gcc-4.2 -O -framework GLUT -Wl,-twolevel_namespace -undefined error
> -arch x86_64 -Wl,-syslibroot,/Developer/SDKs/MacOSX10.6.sdk
> -mmacosx-version-min=10.5 -bundle
> -Wl,-exported_symbols_list,/Applications/MATLAB_R2011b.app/extern/lib/maci64/mexFunction.map
> -o "RT_invcdf.mexmaci64" RT_invcdf.o
> -L/Applications/MATLAB_R2011b.app/bin/maci64 -lmx -lmex -lmat -lstdc++
>
> Undefined symbols for architecture x86_64:
> "_cdftnc", referenced from:
> _mexFunction in RT_invcdf.o
> "_cdft", referenced from:
> _mexFunction in RT_invcdf.o
> "_cdfpoi", referenced from:
> _mexFunction in RT_invcdf.o
> "_cdfnor", referenced from:
> _mexFunction in RT_invcdf.o
> "_cdfnbn", referenced from:
> _mexFunction in RT_invcdf.o
> "_cdfgam", referenced from:
> _mexFunction in RT_invcdf.o
> "_cdffnc", referenced from:
> _mexFunction in RT_invcdf.o
> "_cdff", referenced from:
> _mexFunction in RT_invcdf.o
> "_cdfchn", referenced from:
> _mexFunction in RT_invcdf.o
> "_cdfchi", referenced from:
> _mexFunction in RT_invcdf.o
> "_cdfbin", referenced from:
> _mexFunction in RT_invcdf.o
> "_cdfbet", referenced from:
> _mexFunction in RT_invcdf.o
> ld: symbol(s) not found for architecture x86_64
> collect2: ld returned 1 exit status
>
> mex: link of ' "RT_invcdf.mexmaci64"' failed.
>
> I tried to add the -m64 for the CFLAGS, CXXFLAGS and LDFLAGS, but the
> error remains the same.

Subject: Compiling RT_invcdf.c file with mex on MacOS X

From: Nicolas

Date: 8 Feb, 2012 14:46:16

Message: 3 of 3

Hi Brian,

You were right, the mex command succeded to compile when i supplied the 2 files " ipmpar.c" and "dcdflib.c".

Thanks a lot,
Nicolas

Brian Arnold <Brian.Arnold@mathworks.com> wrote in message <4F3286A4.2070606@mathworks.com>...
> Hi Nicolas,
>
> If the specified symbols cannot be found, it's because their source code
> or binaries haven't been supplied with the MEX command.
>
> When I search the Internet for RT_invcdf.c, several of the top hits link
> to this snippet of code for invoking MEX to compile this file:
>
> if strcmp(computer,'PCWIN')
> mex RT_invcdf.c ipmpar.c dcdflib.c
> else %choose your own compiler flags for gnu -O2 is conservative but it
> will work...
> mex RT_invcdf.c ipmpar.c dcdflib.c CFLAGS='$CFLAGS -Wall -O2'
> %aggressive compilation by Intel ICC compiler on Linux worked as well
> (30% faster)
> %Pentium 3 and other IA-32 chips
> mex /opt/intel/compiler60/ia32/lib/*.a RT_invcdf.c ipmpar.c dcdflib.c
> CC='icc' LD='gcc' CFLAGS='-parallel' COPTIMFLAGS='-ip -axK -O3'
> end
>
> It appears that the MEX command for RT_invcdf.c requires two other
> source files, at least one of which is likely to contain the missing
> symbols. So it would appear that you need to add ipmpar.c and dcdflib.c
> to your MEX command. Try that.
>
> HTH,
>
> Brian
>
>
> On 2/7/12 8:26 AM, Nicolas wrote:
> > I am running MATLAB 2011b on MacOS 10.7.2. I need to use the RT_invcdf.c
> > fonction. When compiling it using mex command, I got the following error:
> >
> > $/Applications/MATLAB_R2011b.app/bin/mex -v /Users/Nicolas/src/RT_invcdf.c
> > -> mexopts.sh sourced from directory (DIR = $PREF_DIR)
> > FILE = /Users/Nicolas/.matlab/R2011b/mexopts.sh
> > ----------------------------------------------------------------
> > -> MATLAB = /Applications/MATLAB_R2011b.app
> > -> CC = gcc-4.2
> > -> CC flags:
> > CFLAGS = -fno-common -no-cpp-precomp -arch x86_64 -isysroot
> > /Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.5 -fexceptions
> > CDEBUGFLAGS = -g
> > COPTIMFLAGS = -O2 -DNDEBUG
> > CLIBS = -L/Applications/MATLAB_R2011b.app/bin/maci64 -lmx -lmex -lmat
> > -lstdc++
> > arguments = -DMX_COMPAT_32
> > -> CXX = g++-4.2
> > -> CXX flags:
> > CXXFLAGS = -fno-common -no-cpp-precomp -fexceptions -arch x86_64
> > -isysroot /Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.5
> > CXXDEBUGFLAGS = -g
> > CXXOPTIMFLAGS = -O2 -DNDEBUG
> > CXXLIBS = -L/Applications/MATLAB_R2011b.app/bin/maci64 -lmx -lmex -lmat
> > -lstdc++
> > arguments = -DMX_COMPAT_32
> > -> FC = gfortran
> > -> FC flags:
> > FFLAGS = -fexceptions -fbackslash
> > FDEBUGFLAGS = -g
> > FOPTIMFLAGS = -O
> > FLIBS = -L/Applications/MATLAB_R2011b.app/bin/maci64 -lmx -lmex -lmat -L
> > -lgfortran -L -lgfortranbegin
> > arguments = -DMX_COMPAT_32
> > -> LD = gcc-4.2
> > -> Link flags:
> > LDFLAGS = -framework GLUT -Wl,-twolevel_namespace -undefined error -arch
> > x86_64 -Wl,-syslibroot,/Developer/SDKs/MacOSX10.6.sdk
> > -mmacosx-version-min=10.5 -bundle
> > -Wl,-exported_symbols_list,/Applications/MATLAB_R2011b.app/extern/lib/maci64/mexFunction.map
> >
> > LDDEBUGFLAGS = -g
> > LDOPTIMFLAGS = -O
> > LDEXTENSION = .mexmaci64
> > arguments = -> LDCXX = -> Link flags:
> > LDCXXFLAGS = LDCXXDEBUGFLAGS = LDCXXOPTIMFLAGS = LDCXXEXTENSION =
> > arguments =
> > ----------------------------------------------------------------
> >
> > -> gcc-4.2 -c -I/Applications/MATLAB_R2011b.app/extern/include
> > -I/Applications/MATLAB_R2011b.app/simulink/include -DMATLAB_MEX_FILE
> > -fno-common -no-cpp-precomp -arch x86_64 -isysroot
> > /Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.5 -fexceptions
> > -DMX_COMPAT_32 -O2 -DNDEBUG "/Users/Nicolas/src/RT_invcdf.c"
> >
> > -> gcc-4.2 -O -framework GLUT -Wl,-twolevel_namespace -undefined error
> > -arch x86_64 -Wl,-syslibroot,/Developer/SDKs/MacOSX10.6.sdk
> > -mmacosx-version-min=10.5 -bundle
> > -Wl,-exported_symbols_list,/Applications/MATLAB_R2011b.app/extern/lib/maci64/mexFunction.map
> > -o "RT_invcdf.mexmaci64" RT_invcdf.o
> > -L/Applications/MATLAB_R2011b.app/bin/maci64 -lmx -lmex -lmat -lstdc++
> >
> > Undefined symbols for architecture x86_64:
> > "_cdftnc", referenced from:
> > _mexFunction in RT_invcdf.o
> > "_cdft", referenced from:
> > _mexFunction in RT_invcdf.o
> > "_cdfpoi", referenced from:
> > _mexFunction in RT_invcdf.o
> > "_cdfnor", referenced from:
> > _mexFunction in RT_invcdf.o
> > "_cdfnbn", referenced from:
> > _mexFunction in RT_invcdf.o
> > "_cdfgam", referenced from:
> > _mexFunction in RT_invcdf.o
> > "_cdffnc", referenced from:
> > _mexFunction in RT_invcdf.o
> > "_cdff", referenced from:
> > _mexFunction in RT_invcdf.o
> > "_cdfchn", referenced from:
> > _mexFunction in RT_invcdf.o
> > "_cdfchi", referenced from:
> > _mexFunction in RT_invcdf.o
> > "_cdfbin", referenced from:
> > _mexFunction in RT_invcdf.o
> > "_cdfbet", referenced from:
> > _mexFunction in RT_invcdf.o
> > ld: symbol(s) not found for architecture x86_64
> > collect2: ld returned 1 exit status
> >
> > mex: link of ' "RT_invcdf.mexmaci64"' failed.
> >
> > I tried to add the -m64 for the CFLAGS, CXXFLAGS and LDFLAGS, but the
> > error remains the same.

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
mex Nicolas 7 Feb, 2012 08:29:13
64bit Nicolas 7 Feb, 2012 08:29:13
mexmaci64 Nicolas 7 Feb, 2012 08:29:13
rt_invcdf Nicolas 7 Feb, 2012 08:29:13
rt_cdf Nicolas 7 Feb, 2012 08:29:13
rtools Nicolas 7 Feb, 2012 08:29:13
matlab Nicolas 7 Feb, 2012 08:29:13
rssFeed for this Thread

Contact us at files@mathworks.com