Watch this Author's files
I have received a couple of email asking me how to compile. Here how I proceeds in 2 steps on Linux (Mint 17 distro)
mex -v -c lbfgsb_wrapper.c -largeArrayDims -UDEBUG CFLAGS="\$CFLAGS -O3" ;
mex -v -output lbfgsb_wrapper lbfgsb_wrapper.o Lbfgsb.3.0/lbfgsb32.f Lbfgsb.3.0/linpack32.f Lbfgsb.3.0/timer.f FC="gfortran" -lm -lmwblascompat32 LINKEXPORT='Wl,--version-script,/usr/local/MATLAB/R2014a/extern/lib/glnxa64/mexFunction.map'
It is a colleague of mine who found out how to compile, therefore I am afraid I cannot explain why it works.
Problem sloved. It seems that Matlab R2014a does not allow to compile Fortran and C in a single MEX call. I believe that it allowed to link the files automatically.
I had to compile the Fortran code to .o objects and link them to the .c files manually.
I managed to compile the Fortran part by splitting into 2 MEX calls:
mex Lbfgsb.3.0/lbfgsb.f Lbfgsb.3.0/linpack.f Lbfgsb.3.0/timer.f -lm -lmwblas CFLAGS="\$CFLAGS -O3"FC="gfortran"
mex -v lbfgsb_wrapper.c -largeArrayDims -UDEBUG ;
The Fortran part is fine, but not the C compilation. I get the following error message:
Error using mex
/tmp/mex_29407351995475_5199/lbfgsb_wrapper.o: In function `mexFunction':
lbfgsb_wrapper.c:(.text+0x738): undefined reference to `setulb_'
collect2: error: ld returned 1 exit status
I have tried to play with the -DNOUNDERSCORE -UUPPERCASE_FORTRAN flags but none of them seem to help.
How can I fix this issue?
Thank you very much
I have tried to compile it under Linux Mint 17, with Matlab 2014a. I got the following error message:
Error using mex
Cannot compile both C and FORTRAN source files in a single call to MEX.
Error in compile_mex (line 61)
mex -v lbfgsb_wrapper.c -largeArrayDims -UDEBUG ...
I've tried to find out about this error but it is nowhere to be found, as if it is an issue related to Matlab 2014 only.