Web lists-archives.com

[Mingw-users] Problems creating linkable file from MSVC .lib

I'm trying to link my mingw gcc project to two hardware driver libraries presumably compiled with MSVC.

The first one worked fine following the guide on the mingw site... I used reimp to create a .def file from the .lib, then dlltool to create the .a file I imported into my project.

The second one is yet to work for me. If I run reimp on the .lib, it produces no output (though it pulls in/creates a 1-byte .dll in the working directory). If I run reimp -S on the lib, though, it does list all of the symbols.

Next I tried using both gendef and pexports to create a def file from the lib. Either way looks pretty much the same. Here's the output from gendef, truncated: 

; Definition file of vcand32.dll
; Automatic generated by gendef
; written by Kai Tietz 2008
LIBRARY "vcand32.dll"

Then I use dlltool to create a .a file from that and the original dll. The problem is, no matter what options I use to create the .a file, the linker gives an error like "undefined reference to `_imp__ncdOpenDriver'" for every call. Notice there is one underscore before imp and two after. If I run `nm libvcand32.a | grep imp` I get lines like this:  

00000000 I __imp__ncdOpenPort
00000000 I __imp__ncdOpenDriver
00000000 I __imp__ncdGetState
00000000 I __imp__ncdGetReceiveQueueLevel
00000000 I __imp__ncdGetEventString
00000000 I __imp__ncdGetErrorString

They always have at least two underscores before "imp". I can adjust the number of underscores AFTER "imp" using dlltool options like -U, --no-leading-underscore. I can also add an alias for every symbol with THREE underscores before "imp" using the -C option in dlltool. However, it doesn't seem that there's an option to remove one underscore before imp.

If I run the same `nm` command on the .a file I created for the other driver library (the one that DOES work) it also has two underscores before imp, every time, but the linker is fine with it in that case.

Any ideas/suggestions? Am I missing something here?

Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
MinGW-users mailing list

This list observes the Etiquette found at 
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

You may change your MinGW Account Options or unsubscribe at:
Also: mailto:mingw-users-request@xxxxxxxxxxxxxxxxxxxxx?subject=unsubscribe