Please download (it's free) the Dependency Walker 64 program and use it to analyze the mex file you created. Dependency Walker will tell you what dll's are missing and causing the "Attempt to access invalid address".
This problem can be solved if you are using Windows 7 64bit. In the case of Windows 8.1 I could not get it to work as the dylib libraries from the cygwin fortran make use of some dll's that are no longer available in Windows 8.1
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.