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
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 succeded to compile and test the mex module for Windows 7 x64 (Sp1) linking with the multithreded OpenBlas. In this way one can take advantage of the multicore architecture of the available CPU. For the Windows operating system the process is rather convoluted and delicate (one can easily get into the so called "dll hell" problem). The solution is indeed based on creating a dll file. I got it working following a script from Roland, so many thanks to him who pioneered a way to compile using Cygwin and gracefully shared his own script.
The idea is the following:
1) install Openblas and add its lib folder to the $Path$ Environment variable.
2) install Cygwin64 (the Devel package)
3) make sure you have SDK 7.1 installed along with Visual Studio 10.0 (it's free) and all the updates for Win7.
4) add to the $Path$ environment variable "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64"
5) find and copy the x64 version of IESHIMS.dll into a folder added to $Path$ environment variable. (I know, this is counterintuitive and seems esoteric but if you don't it may not work) To check that this is needed one can use "Dependency Walker".
6) open the Cygwin64 terminal and go to the "lbfgsb3.0_mex1.2" folder and make sure the "Lbfgsb.3.0" subfolder with all its files is inside (if not download it).
7) Type (or creat a .sh script to run at once):
Could you please post detailed instructions for how to compile the lbfgsb_wrapper in Windows 7 64bit?
I was only able to compile in Linux and Mac OS X so far . I also linked with the OpenBlas library which is very fast ( if you have a multi-core cpu).