So I was happily using this code on my 32-bit workstation and now am enjoying trying to get it to work on my 64-bit laptop... I have followed Daniel's instructions below and have managed to get the .mexw64 file to compile, but when I try to run the example I get
Invalid MEX-file 'C:\Users\...\lbfgsb.3.0_1.2\lbfgsb_wrapper.mexw64': Attempt to access invalid address.
Error in lbfgsb (line 179)
[f, task, csave, lsave, isave, dsave] = ...
Error in example_NNLS (line 100)
[xk, ~, info] = lbfgsb(fun, l, u, opts );
Probably a longshot, but does anyone have any suggestion what could be causing this? I am guessing some kind of library linking issue but nothing comes up during the compilation process...
Sorry for my late reply, I haven't checked the posts in a while. I think the problem you describe is quite simple, namely you have to add in the PATH variable in Windows the path to the "lib" command from the Visual Studio folder.
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.
I have the same problem as Alexandre. When I try to compile it under Linux with matlab R2014a, I get the following error:
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 ...
Anyone had meet this problem? Please kindly show me the solution, I'm really in trouble.
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.