I know there is a tool called Dll to lib but the developer is asking $1000. I only need to convert one library, once, so its not easy to justify that price.
I tried IMPLIB32.EXE, but I just get empty .lib files. How can I accomplish this? Perhaps I can write a simple conversion app?
Added1:
The Dll's are typically stdcall not cdecl and written in older C like languages NOT C# or .NET or C++. I now need to call them from C++ apps. An example would be the SQLite.dll or zlib.dll. I do not have access to the .lib files for these dll's.
Added2:
I re-wrote this code for VS2008 http://floodyberry.wordpress.com/2008/09/08/generating-dll-wrappers/ and included the example Dll etc downloadable here: http://www.transferbigfiles.com/Get.aspx?id=7d86fa0b-6ddc-4f6f-8d31-2c20824aae9a This in turn makes a project that creates a Dll. When I try to compile the Dll I get the linker error: AddShow.dll : fatal error LNK1107: invalid or corrupt file: cannot read at 0x300 Described here: http://list.isis.vanderbilt.edu/pipermail/udm-users/2006-March/000664.html Not sure how to proceed. So close yet so far
Next we move to this method
http://www.coderetard.com/2009/01/21/generate-a-lib-from-a-dll-with-visual-studio/
Running dumpbin with the argument /exports C:\path\to\AddShow.dll does absolutly nothing After some research
http://msdn.microsoft.com/en-us/library/aa446532.aspx it seems that mspdb71.dll (now mspdb80.dll) is needed from the common/ide folder dumpbin.exe now runs with error:
fatal error LNK1106: invalid file or disk full: cannot seek to 0x6179A These threads suggests the version of dumpbin.exe might be the issue
I have Microsoft (R) COFF/PE Dumper Version 9.00.30729.01
So I tried Microsoft (R) COFF Binary File Dumper Version 5.12.8078 with no success. After much reading I am no closer
http://support.microsoft.com/kb/815645 http://support.microsoft.com/kb/839286 http://markmail.org/message/p5vwzyfyv3bs6z34 http://fixunix.com/programmer/94825-fatal-error-lnk1106-invalid-file-disk-full.html
When I run ProcMon I see the first occurance of queryopen and sqlite3.dll when svchost.exe tries to open it and fails with the error PATH NOT FOUND. the path is C:\Program Files\Microsoft Visual Studio 9.0\VC\bin\SQLITE3.DLL and is correct. If I put it at the root of the C drive then I get NAME NOT FOUND errors:
C:\Program Files\Microsoft Visual Studio 9.0\VC\bin\link.exe.Local
C:\Program Files\Microsoft Visual Studio 9.0\VC\bin\dumpbin.exe.Local
from link.exe and dumpbin.exe respectivly. Im using XPSP3 not Vista and this is about the limit of my knowledge of sysinternals. what are these .local files?
(csrss.exe is also not able to find a few manifest files.)
So no success yet, just more mystery
Added 3:
I tried to run dumpbin.exe from its installed location, \Program Files\Microsoft Visual Studio 8\VC\bin, but the OS said it couldn't find mspdb80.dll. I copied mspdb80.dll from \Program Files\Microsoft Visual Studio 8\Common7\IDE to try to get dumpbin.exe to run.
now I get the error: "c1902 program database manager mismatch please check your installation"
If I remove mspdb80.dll from \Program Files\Microsoft Visual Studio 8\VC\bin the error goes away! but I can't run dumpbin.exe.
Added 4:
I was finally able to get dumpbin to run by copying the following files to a folder:
dumpbin.exe link.exe lib.exe mspdb80.dll
I did get the error:
fatal error LNK1248: image size (FFFFFXXX) exceeds maximum allowable size (80000000)
once, but replacing the dll fixed that. Presumably it got corrupted?
I then moved onto the next step in the instructions: http://www.coderetard.com/2009/01/21/generate-a-lib-from-a-dll-with-visual-studio/ http://support.microsoft.com/kb/131313 and got the error: warning lnk4017 statement not supported for the target platform ignored This turns out to be because I specified the .dll instead of the .def file.
The resulting .Lib and .exp files are then added to the VS2008 project and compile and run. The debugger then reported an error: Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call...
As mentioned here http://stackoverflow.com/questions/1465207/run-time-check-failure-0-the-value-of-esp-was-not-properly-saved-across-a-fun this is because I used stdcall in my dll and declared __cdecl in my app.
extern "C" { // put Dll C function prototypes here
int __cdecl AddTwoNum(int n, double f); // __stdcall
}
So changing this to __stdcall should fix it you would think.. but alas no.
now I get a linking error: error LNK2001: unresolved external symbol _AddTwoNum@12
This is a decorated function name for some reason. Why?
Added n:
Well this turned out to be because the .lib file was made using a dll that with STDCALL functions. STDCALL requiers the caller to clean up the stack so the number of bytes of the arguments is appended to the function name with an @ sign. IN this case I had three 4Byte iintegers for a total of 12 bytes.
Once I remade the .lib file from a dll created with the CDECL calling convention then all was good.