Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiling on Mac Lion #53

Open
GoogleCodeExporter opened this issue Mar 7, 2016 · 6 comments
Open

Compiling on Mac Lion #53

GoogleCodeExporter opened this issue Mar 7, 2016 · 6 comments

Comments

@GoogleCodeExporter
Copy link

Good evening, 

I am trying to compile randomforest-matlab for Mac Lion in Matlab E2012a. 
However, using the precompiled files I get the following error when trying to 
run "test_ClassRF_extensively". 

1,Too less/many parameters: You supplied 15One or more output arguments not 
assigned during call to "mexClassRF_train".

Error in classRF_train (line 347)
    [nrnodes,ntree,xbestsplit,classwt,cutoff,treemap,nodestatus,nodeclass,bestvar,ndbigtree,mtry
    ...

Error in test_ClassRF_extensively (line 13)
    model=classRF_train(inputs',outputs,1000);

I have followed all previous instructions, however to no success. I have 
installed fortran (however a very old version) that is unable to be located in 
the mex - setup. I am looking for a pointer if possible on to how get RF 
working for Matlab. 

Original issue reported on code.google.com by d.leight...@googlemail.com on 26 Dec 2012 at 5:52

@GoogleCodeExporter
Copy link
Author

try the following in the RF_Class_C folder

as fortran is needed to compile into a .o file do the following from the 
terminal (not the matlab terminal but the system terminal)

gfortran  -fpic -march=native -c src/rfsub.f -o rfsub.o

gfortran may be g77 or f77 or something else depending on how fortran is 
invoked from the command prompt

once the rfsub.o is generated (just check if its in the RF_Class_C folder )

invoke the following from matlab prompt (i am assuming that mex -setup was 
successful in finding the C compiler (gcc) or g++)

mex src/mex_ClassificationRF_train.cpp  src/classRF.cpp src/classTree.cpp 
src/rfutils.cpp src/cokus.cpp rfsub.o -o mexClassRF_train -lm -DMATLAB -O -v

and then

mex src/mex_ClassificationRF_predict.cpp  src/classRF.cpp src/classTree.cpp 
src/rfutils.cpp src/cokus.cpp rfsub.o -o mexClassRF_predict -lm -DMATLAB -O -v


that should generate the training predict mex files. Note that do comment out 
the compile_linux/compile_windows file in the tutorial file before running the 
tutorial file else it will zap the mex files.

if you get the above steps working then maybe a better source would be the svn 
source which has some bug fixes etc. The compilation steps would remain the 
same.

Original comment by abhirana on 26 Dec 2012 at 6:11

  • Changed state: Accepted

@GoogleCodeExporter
Copy link
Author

Thank you for a very quick reply, and happy new year. I have tried running the 
command:-

gfortran  -fpic -march=native -c src/rfsub.f -o rfsub.o

And receive the following error:-

src/rfsub.f -o rfsub.o
src/rfsub.f:0: error: bad value (native) for -march= switch
src/rfsub.f:0: error: bad value (native) for -mtune= switch

Any guidance would be greatly appreciated

Dan 

Original comment by d.leight...@googlemail.com on 26 Dec 2012 at 8:30

@GoogleCodeExporter
Copy link
Author

Happy new year to you too

Try this.  Remove the -march=native string in the gfortran line and rerun the 
command. Some old gcc version don't have that optimization flag

Original comment by abhirana on 26 Dec 2012 at 10:52

@GoogleCodeExporter
Copy link
Author

I have been able to compile the rfsub file. However another problem presents 
itself in Matlab (I m able to compile other mex files using the compiler). The 
error is:-

mex src/mex_ClassificationRF_train.cpp  src/classRF.cpp src/classTree.cpp 
src/rfutils.cpp src/cokus.cpp rfsub.o -o mexClassRF_train -lm -DMATLAB -O -v

**************************************************************************
  Warning: Neither -compatibleArrayDims nor -largeArrayDims is selected. 
           Using -compatibleArrayDims. In the future, MATLAB will require
           the use of -largeArrayDims and remove the -compatibleArrayDims
           option. For more information, see:
           http://www.mathworks.com/help/techdoc/matlab_external/bsflnue-1.html
**************************************************************************

-> mexopts.sh sourced from directory (DIR = $PREF_DIR)
   FILE = /Users/user/.matlab/R2012a/mexopts.sh
----------------------------------------------------------------
->    MATLAB                = /Applications/MATLAB_R2012a.app
->    CC                    = llvm-gcc-4.2
->    CC flags:
         CFLAGS             = -fno-common -no-cpp-precomp -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/ -mmacosx-version-min=10.5  -fexceptions
         CDEBUGFLAGS        = -g
         COPTIMFLAGS        = -O2 -DNDEBUG
         CLIBS              = -L/Applications/MATLAB_R2012a.app/bin/maci64 -lmx -lmex -lmat -lstdc++
         arguments          =  -DMATLAB -DMX_COMPAT_32
->    CXX                   = llvm-g++-4.2
->    CXX flags:
         CXXFLAGS           = -fno-common -no-cpp-precomp -fexceptions -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/ -mmacosx-version-min=10.5
         CXXDEBUGFLAGS      = -g
         CXXOPTIMFLAGS      = -O2 -DNDEBUG
         CXXLIBS            = -L/Applications/MATLAB_R2012a.app/bin/maci64 -lmx -lmex -lmat -lstdc++
         arguments          =  -DMATLAB -DMX_COMPAT_32
->    FC                    = /usr/local/bin/gfortran
->    FC flags:
         FFLAGS             = -fexceptions -m64 -fbackslash
         FDEBUGFLAGS        = -g
         FOPTIMFLAGS        = -O5 -funroll-loops -ftree-vectorize
         FLIBS              = -L/Applications/MATLAB_R2012a.app/bin/maci64 -lmx -lmex -lmat -L/usr/local/lib/ -lgfortran -L/usr/local/lib/gcc/i686-apple-darwin8/4.2.3/x86_64/ -lgfortranbegin
         arguments          =  -DMATLAB -DMX_COMPAT_32
->    LD                    = llvm-gcc-4.2
->    Link flags:
         LDFLAGS            = -Wl,-twolevel_namespace -undefined error -arch x86_64 -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/ -mmacosx-version-min=10.5 -bundle -Wl,-exported_symbols_list,/Applications/MATLAB_R2012a.app/extern/lib/maci64/mexFunction.map
         LDDEBUGFLAGS       = -g
         LDOPTIMFLAGS       = -O
         LDEXTENSION        = .mexmaci64
         arguments          =  -lm
->    LDCXX                 = 
->    Link flags:
         LDCXXFLAGS         = 
         LDCXXDEBUGFLAGS    = 
         LDCXXOPTIMFLAGS    = 
         LDCXXEXTENSION     = 
         arguments          =  -lm
----------------------------------------------------------------

-> llvm-g++-4.2 -c  -I/Applications/MATLAB_R2012a.app/extern/include 
-I/Applications/MATLAB_R2012a.app/simulink/include -DMATLAB_MEX_FILE 
-fno-common -no-cpp-precomp -fexceptions -arch x86_64 -isysroot 
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/S
DKs/MacOSX10.7.sdk/ -mmacosx-version-min=10.5  -DMATLAB -DMX_COMPAT_32 -O2 
-DNDEBUG  "src/mex_ClassificationRF_train.cpp"

-> llvm-g++-4.2 -c  -I/Applications/MATLAB_R2012a.app/extern/include 
-I/Applications/MATLAB_R2012a.app/simulink/include -DMATLAB_MEX_FILE 
-fno-common -no-cpp-precomp -fexceptions -arch x86_64 -isysroot 
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/S
DKs/MacOSX10.7.sdk/ -mmacosx-version-min=10.5  -DMATLAB -DMX_COMPAT_32 -O2 
-DNDEBUG  "src/classRF.cpp"

-> llvm-g++-4.2 -c  -I/Applications/MATLAB_R2012a.app/extern/include 
-I/Applications/MATLAB_R2012a.app/simulink/include -DMATLAB_MEX_FILE 
-fno-common -no-cpp-precomp -fexceptions -arch x86_64 -isysroot 
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/S
DKs/MacOSX10.7.sdk/ -mmacosx-version-min=10.5  -DMATLAB -DMX_COMPAT_32 -O2 
-DNDEBUG  "src/classTree.cpp"

-> llvm-g++-4.2 -c  -I/Applications/MATLAB_R2012a.app/extern/include 
-I/Applications/MATLAB_R2012a.app/simulink/include -DMATLAB_MEX_FILE 
-fno-common -no-cpp-precomp -fexceptions -arch x86_64 -isysroot 
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/S
DKs/MacOSX10.7.sdk/ -mmacosx-version-min=10.5  -DMATLAB -DMX_COMPAT_32 -O2 
-DNDEBUG  "src/rfutils.cpp"

-> llvm-g++-4.2 -c  -I/Applications/MATLAB_R2012a.app/extern/include 
-I/Applications/MATLAB_R2012a.app/simulink/include -DMATLAB_MEX_FILE 
-fno-common -no-cpp-precomp -fexceptions -arch x86_64 -isysroot 
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/S
DKs/MacOSX10.7.sdk/ -mmacosx-version-min=10.5  -DMATLAB -DMX_COMPAT_32 -O2 
-DNDEBUG  "src/cokus.cpp"

-> llvm-gcc-4.2 -O -Wl,-twolevel_namespace -undefined error -arch x86_64 
-Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.plat
form/Developer/SDKs/MacOSX10.7.sdk/ -mmacosx-version-min=10.5 -bundle 
-Wl,-exported_symbols_list,/Applications/MATLAB_R2012a.app/extern/lib/maci64/mex
Function.map -o  "mexClassRF_train.mexmaci64"  mex_ClassificationRF_train.o 
classRF.o classTree.o rfutils.o cokus.o  "rfsub.o"  -lm 
-L/Applications/MATLAB_R2012a.app/bin/maci64 -lmx -lmex -lmat -lstdc++

ld: warning: ignoring file rfsub.o, file was built for i386 which is not the 
architecture being linked (x86_64): rfsub.o
Undefined symbols for architecture x86_64:
  "_buildtree_", referenced from:
      classRF(double*, int*, int*, int*, int*, int*, int*, int*, int*, int*, int*, int*, double*, double*, int*, int*, int*, double*, double*, double*, double*, int*, int*, int*, int*, int*, int*, double*, double*, int*, double*, int*, int*, double*, int*, int, double*, double*, int*)in classRF.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status

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

Error using mex (line 206)
Unable to complete successfully.

Thanks very much for your help and time

Dan

Original comment by d.leight...@googlemail.com on 27 Dec 2012 at 10:43

@GoogleCodeExporter
Copy link
Author

Hi Dan

looks like the fortran compiler you are using is generating 32 bit binaries 
that cannot be merged with the 64-bit binaries generated in matlab mex.

you will have to update to a fortran version that generates 64 bit binaries or 
use a 32bit matlab (the latter might not be possible because i guess mathworks 
has cancelled developing 32 bits for many architectures) maybe macports/fink 
has 64bit fortran.

Original comment by abhirana on 27 Dec 2012 at 7:16

@GoogleCodeExporter
Copy link
Author

After checking, I already had the correct compiler installed. I reinstalled the 
compiler and success - everything in post #1 works. Thank you very much for all 
your assistance. 

Happy new year.

Dan  

Original comment by d.leight...@googlemail.com on 27 Dec 2012 at 9:03

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant