Open GoogleCodeExporter opened 9 years ago
hello
what happens if you write mex on matlab's command prompt? and i am guessing
you're running mex via the command prompt (on running makefile)... what is the
output if you run mex on command prompt then?
i am guessing you might not have matlab's mex in the command prompt but some
other mex command and that's why -o is not being accepted
what you can instead do is
navigate to RF_Reg_C and run the following two commands (do both steps within
matlab's command prompt)
mex mex_regressionRF_train.cpp reg_RF.cpp cokus.cpp -o mexRF_train -DMATLAB
mex mex_regressionRF_predict.cpp reg_RF.cpp cokus.cpp -o mexRF_predict -DMATLAB
btw are you using RF_Class_C you'll have to run a different set of commands
(lines 22 and 23 in
https://code.google.com/p/randomforest-matlab/source/browse/trunk/RF_Class_C/com
pile_linux.m#22)
Original comment by abhirana
on 26 Aug 2014 at 4:49
Hello abhirana, thanks for your comments.
On typing 'mex', I get
Error using mex
Not enough input arguments.
and on 'help mex':
Contents of mex:
virtualinport - describes the virtual input port block
Contents of mex:
rtwmakecfg - Add include and source directories to make files.
mex is both a directory and a function.
mex Compile mex-function
Usage:
mex [options ...] file [files ...]
Description:
...
Command Line Options Available on All Platforms:
...
-O
Optimize the object code. Optimization is enabled by default and
by including this option on the command line. If the -g option
appears without the -O option, optimization is disabled.
...
For more information, see
http://www.mathworks.com/help/matlab/ref/mex.html
...
(full output in file attached)
The command documentation matches with the documentation on the original matlab
support page, but there is really no option -o, only one option -O for
optimization. Which is, why both the commands you posted, when executed in the '
/Users/Marie/Documents/MATLAB' (where the files listed lay) give the same error.
Did Matlab maybe change the syntax for the mex command?
When I run cc = mex.getCompilerConfigurations i get a 3x1 struct, of which the
third entry obviously describes the gfortran compiler.
Original comment by rosmarie...@gmail.com
on 26 Aug 2014 at 8:01
Attachments:
Somehow, after all, I wasn't quite sure if I had my compilers and settings in
Matlab all right. So I started right over again. These were the steps I took,
and at least I got a working compiler setup, which is at least something:
1) Re-installed Xcode from App-Store
2) Installed latest version of CommandLineTools (OS X 10.9) for Xcode - Late
August 2014
from official Developers Website: https://developer.apple.com/downloads/index.action
3) Download the latest precompiled GNU compilers. Xcode includes the GNU C and
C++ compilers,
but the versions are sometimes a bit dated. Followed procedure described here:
https://wiki.helsinki.fi/display/HUGG/Installing+the+GNU+compilers+on+Mac+OS
+X#InstallingtheGNUcompilersonMacOSX-InstructionsforMacOS10.9(Mavericks)withXcode5
Copied the file from http://hpc.sourceforge.net to my home folder, then used
sudo tar xvf gcc-4.9-bin.tar -C /
to unpack its content to my root directory.
Then, since my terminal type (echo $SHELL) was /bin/bash, used
echo 'export PATH=/usr/local/bin:$PATH' >> ~/.bash_profile
to ensure the newly installed compilers are used by default. This worked fine, as this output suggests:
me:~ Marie$ gcc -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-
include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.3.0
Thread model: posix
me:~ Marie$ gfortran -v
Es werden eingebaute Spezifikationen verwendet.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-apple-darwin13.1.0/4.9.0/lto-wrapper
Ziel: x86_64-apple-darwin13.1.0
Konfiguriert mit: ../gcc-4.9.0/configure --enable-languages=fortran
Thread-Modell: posix
gcc-Version 4.9.0 (GCC)
4) Since, back in MATLAB, I got this error
>> mex -setup FORTRAN
Error using mex
No supported compiler or SDK was found. For options, visit
http://www.mathworks.com/support/compilers/R2014a/maci64.
I followed some advice from this link:
http://www.mathworks.com/matlabcentral/answers/103904-can-i-use-xcode-5-as-my-c-or-c-
compiler-in-matlab-8-1-r2013a-or-matlab-8-2-r2013b
cd(matlabroot)
cd bin
Saving a copy of mexopts.sh as ORIGINAL_mexopts.sh
In the ‘maci64’ section replaced all instances (five) of 10.7 by 10.8,
since in the terminal I checked that this exists:
me:~ Marie$ find `xcode-select -print-path` -name MacOSX10.8.sdk
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/
MacOSX10.8.sdk
me:~ Marie$ find `xcode-select -print-path` -name MacOSX10.9.sdk
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/
MacOSX10.9.sdk
and the MathWorks SupportTeam in the reference above recommended using the older version.
5) finally, in MATLAB, the test:
>> mex -setup
Chose my altered mexopts.sh
>> copyfile(fullfile(matlabroot,'extern','examples','refbook',...
'timestwo.c'), fullfile(pwd), 'f');
>> mex timestwo.c
Successfully compiled this Matlab test file!
But now back to the randomforest case:
I just assumed that -o should stand for the -output option in the current
documentation. Is that right?
>> mex mex_regressionRF_predict.cpp reg_RF.cpp cokus.cpp -output mexRF_predict -DMATLAB
mex_regressionRF_predict.cpp:82:10: error: no matching function for call to
'mxCreateNumericMatrix_700'
plhs[0]=mxCreateNumericMatrix(n_size,1,mxDOUBLE_CLASS,0);
^~~~~~~~~~~~~~~~~~~~~
/Applications/MATLAB_R2014a.app/extern/include/matrix.h:1440:31: note:
expanded from macro 'mxCreateNumericMatrix'
#define mxCreateNumericMatrix mxCreateNumericMatrix_700
^~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/MATLAB_R2014a.app/extern/include/matrix.h:780:46: note:
candidate function not viable: no known conversion from 'int' to
'mxComplexity' for 4th argument
LIBMMWMATRIX_PUBLISHED_API_EXTERN_C mxArray *mxCreateNumericMatrix_700...
^
1 error generated.
mex: compile of ' "mex_regressionRF_predict.cpp"' failed.
Unable to complete successfully.
Unfortunately, I have no idea what to do with this error. The same attempt with
mex_regressionRF_predict.cpp throws a similar, jet longer error message.
I hope at least the first part of the story is conclusive enough to assume that
at least the compilers installed and the settings in MATLAB should be all right
now. Is it?
Any ideas for the mex compilation errors?
Original comment by rosmarie...@gmail.com
on 26 Aug 2014 at 2:14
great. i think you're almost there
yup i think i know the mex issues. the 4th variable earlier used to be bool.
they have changed it to something else.
do this, change
plhs[0]=mxCreateNumericMatrix(n_size,1,mxDOUBLE_CLASS,0);
to
plhs[0]=mxCreateNumericMatrix(n_size,1,mxDOUBLE_CLASS,mxREAL);
if you get any other error let me know
Original comment by abhirana
on 26 Aug 2014 at 6:29
Hey, thats awesome! It just works!
I did the same change that you suggested to every command of the same structure
in the mex_regressionRF_predict.cpp, mex_ClassificationRF_predict.cpp and
mex_ClassificationRF_train.cpp, and they all compiled nicely.
Well, nicely - saying with a warning:
In file included from reg_RF.cpp:65:
./qsort.c:80:42: warning: for loop has empty body [-Wempty-body]
l--;for(;v[l]>vt;l--);
^
./qsort.c:80:42: note: put the semicolon on a separate line to silence this
warning
1 warning generated.
I will attach all the files that I finally used below, so anyone who has a
similar problem may just follow the steps above and use the files.
Thank you very much, abhirana!
Original comment by rosmarie...@gmail.com
on 27 Aug 2014 at 8:41
Attachments:
Hi Abhi and Rosmarie,
It is awesome. I followed the every single step and finally solved my problem
with the compiling.
By the way I still receive this message:
MEX configured to use 'Xcode with Clang' for C language compilation.
Warning: The MATLAB C and Fortran API has changed to support MATLAB
variables with more than 2^32-1 elements. In the near future
you will be required to update your code to utilize the
new API. You can find more information about this at:
http://www.mathworks.com/help/matlab/matlab_external/upgrading-mex-files-to-use-64-bit- api.html.
To choose a different language, select one from the following:
mex -setup C++
mex -setup FORTRAN
and when I choose FORTRAN it gives me an error that:
Error using mex
No supported compiler or SDK was found. For options, visit
http://www.mathworks.com/support/compilers/R2014a/maci64.
but the compiler works seamlessly.
Do you have any idea that where is the problem?
Regards,
Vadoud
Original comment by vad...@gmail.com
on 6 Nov 2014 at 6:41
you can ignore the warning message about elements, unless if you are using
really large matrices.
other than that you should be good to go if you are able to run the tutorial
files are the compilation is done
Original comment by a...@flashbacktechnologies.com
on 6 Nov 2014 at 6:47
Original issue reported on code.google.com by
rosmarie...@gmail.com
on 25 Aug 2014 at 3:49