Web lists-archives.com

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




One underscore at the beginning of a name usually indicates something
within a library that is meant to be called only from within that library
unless you understand the internals of that library well enough to
understand the usually undocumented restrictions on calling it.

I've seen two underscores at the beginning of names related to the CUDA
method of running parts of the program on the GPU of your graphics
board instead of running it on the CPU.

The name of that library suggests that it was compiled to run in 32-bit
mode.  MinGW is usually used in 64-bit mode instead.  It's very difficult
to have part of a program run in 32-bit mode but another part in 64-bit
mode, and still have both parts work.  Drivers are normally required to
run in the same mode as the operating system.

Therefore, something to check for is whether you're trying to reach a
DLL compiled in a different mode from the mode the main program
was compiled in.

Robert

---

Date: Thu, 18 Feb 2016 15:35:15 -0600
From: Chris <chricro@xxxxxxxxx>

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"
EXPORTS
ncdOpenDriver
ncdGetDriverConfig@8
ncdOpenPort@24
ncdSetChannelMode@16
ncdSetChannelOutput@12
ncdSetChannelTransceiver@20
ncdSetChannelParams@20
ncdSetChannelParamsC200@16
ncdSetChannelBitrate@12
ncdSetChannelAcceptance@12
ncdSetTimerRate@8
...

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?

Chris


------------------------------------------------------------------------------
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!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
_______________________________________________
MinGW-users mailing list
MinGW-users@xxxxxxxxxxxxxxxxxxxxx

This list observes the Etiquette found at 
http://www.mingw.org/Mailing_Lists.
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:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:mingw-users-request@xxxxxxxxxxxxxxxxxxxxx?subject=unsubscribe