Axter
asked on
GNU GCC *.lib file usage or conversion for WIN32
I have the following code that I'm trying to get to work with the GNU compiler (3.x):
http://code.axter.com/leaktracker.h
This works just fine with VC++ and Borland. To get it to work with Borland, I used a conversion progran that converted MS Lib file to a lib file compatible with Borland.
I'm looking for a tool that can help me make a similar conversion for the GNU compiler.
Does any one know of a tool or a method to get either MS Lib files or Borland Lib files to work with the GNU 3.x compiler, or a method to convert the file to something GNU can use?
Does the GNU compiler have anything similar to a *.lib file in Windows?
Using the GNU compiler, when you create a static DLL in windows, does it create just a *.a file, or both *.a and *.dll file?
If it creates both, then does the *.a file work like a *.lib file, and is it needed at runtime?
http://code.axter.com/leaktracker.h
This works just fine with VC++ and Borland. To get it to work with Borland, I used a conversion progran that converted MS Lib file to a lib file compatible with Borland.
I'm looking for a tool that can help me make a similar conversion for the GNU compiler.
Does any one know of a tool or a method to get either MS Lib files or Borland Lib files to work with the GNU 3.x compiler, or a method to convert the file to something GNU can use?
Does the GNU compiler have anything similar to a *.lib file in Windows?
Using the GNU compiler, when you create a static DLL in windows, does it create just a *.a file, or both *.a and *.dll file?
If it creates both, then does the *.a file work like a *.lib file, and is it needed at runtime?
ASKER
>>But you can also put the functions from the dll in the imports section of a def file. afaik that would work in all three compilers.
I'm already doing that. How would that help me with GNU compiler?
I'm already doing that. How would that help me with GNU compiler?
Excuses, seems I made a wrong assumption. I thought gcc also would accept a .def file as input, but it seems you need to create a .lib file...
ASKER
After much Google searching, I found the solution. I'm adding this information here so if anyone else is looking for it, they'll know how to do it.
I need to make a *.a, which is similar to the *.lib files for MS and Borland.
To make a *.a file I used the dlltool which comes Dev-C++. Actually, it probably comes with the GNU compiler, but I haven't verified that yet.
Example command line use:
dlltool --output-lib leaktracker_gcc.a --input-def leaktracker.def --dllname leaktracker.dll
Important note here, don't use a full directory path for the DLL, like the following:
dlltool --output-lib leaktracker_gcc.a --input-def leaktracker.def --dllname c:\windows\system32\leaktr acker.dll
This will produce a *.a file that looks for DLL named cwindowssystem32leaktracke r.dll
What I had to do was temporarily copy the DLL to the local directory in which I was creating the *.a file.
To simplify things, I copied the *.def file to the local directory as well.
That gave me a leaktracker_gcc.a file which I'm able to use with the GNU g++ compiler.
Example:
g++ test.cpp leaktracker_gcc.a
The DLL doesn't have to be in the system to compile the above test.cpp file, but it does need to be accessable when running the executable.
I need to make a *.a, which is similar to the *.lib files for MS and Borland.
To make a *.a file I used the dlltool which comes Dev-C++. Actually, it probably comes with the GNU compiler, but I haven't verified that yet.
Example command line use:
dlltool --output-lib leaktracker_gcc.a --input-def leaktracker.def --dllname leaktracker.dll
Important note here, don't use a full directory path for the DLL, like the following:
dlltool --output-lib leaktracker_gcc.a --input-def leaktracker.def --dllname c:\windows\system32\leaktr
This will produce a *.a file that looks for DLL named cwindowssystem32leaktracke
What I had to do was temporarily copy the DLL to the local directory in which I was creating the *.a file.
To simplify things, I copied the *.def file to the local directory as well.
That gave me a leaktracker_gcc.a file which I'm able to use with the GNU g++ compiler.
Example:
g++ test.cpp leaktracker_gcc.a
The DLL doesn't have to be in the system to compile the above test.cpp file, but it does need to be accessable when running the executable.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Looks like reimp could do this: http://jrfonseca.planetaclix.pt/projects/gnu-win32/software/reimp/
more info: http://www.mingw.org/mingwfaq.shtml#faq-msvcdll
But you can also put the functions from the dll in the imports section of a def file. afaik that would work in all three compilers.