Web lists-archives.com

Re: [Mingw-users] undefined reference to _imp__*




It appears to be working now.  I am able to successfully build my Fortran project.  I am not seeing the "undefined reference" messages any more.

I think the problem may have been in the LIBRARY section of my DEF file.  I don't think I had the correct DLL name listed there.  After fixing that problem and rebuilding the implib.a file with DLLTOOL, I rebuilt my project and did not see the errors.

For what it's worth, I looked at the imported library using NM -A, and am still seeing 2 underscores in front of the "imp" prefixes, but the linker seems to be happy with that now.

Thank you for your help, Eli.




-----Original Message-----
From: Cervinka, Mitch 
Sent: Wednesday, January 18, 2017 4:37 PM
To: Eli Zaretskii <eliz@xxxxxxx>
Cc: mingw-users@xxxxxxxxxxxxxxxxxxxxx
Subject: RE: [Mingw-users] undefined reference to _imp__*

More confirmation that it's finding the import library ...

I originally just had the name of the library file, without the leading "lib" or the file extension ".a".
Then, in Eclipse, I tried adding, to Project/Properties/"Fortran Build"/"Settings"/"GNU Fortran Linker"/"Libraries (-l)", the following items ...

   myexplib
   myexplib.a
   libmyexplib
   libmyexplib.a

This time, when I built my code, the linker complained about the last 3 files, but did not complain about the first one, and it did not list any of the "undefined reference" messages.

... cannot find -lmyexplib.a
... cannot find -llibmyexplib
... cannot find -llibmyexplib.a

I am not seeing any "cannot find" messages when myexplib is the only item in the list.  Instead, I'm seeing the "undefined reference" messages.

-- -- --

I found the following comment on another website (http://mirrors.zoreil.com/webclub.kcom.ne.jp/ma/colinp/win32/dll/use.html) ...

"Older versions of dlltool used __imp_ as the prefix instead of _imp__. The new prefix is more compatible with Microsoft, and dlltool includes both for backward compatibility, but these type of changes show just how dangerous such a kludge can be."

I checked the version of dlltool I am using.  It is 

   GNU dlltool (GNU Binutils) 2.25.1
   Copyright (C) 2014 Free Software Foundation, Inc.

Is there a newer version of DLLTOOL I should be using?  Or, is there a command-line switch that controls how many leading underscores are generated (i.e. before imp_) ?




-----Original Message-----
From: Cervinka, Mitch 
Sent: Wednesday, January 18, 2017 2:40 PM
To: Eli Zaretskii <eliz@xxxxxxx>
Cc: mingw-users@xxxxxxxxxxxxxxxxxxxxx
Subject: RE: [Mingw-users] undefined reference to _imp__*

Hi Eli,

I'm fairly sure it's finding the import library.  I was seeing different errors earlier when it could not find the library.

I tried adding the -v link switch, as you suggested, but I don't see anything in the output that tells me if it's actually reading the import library.

For what it's worth, I using the Eclipse(Mars version) IDE to build the code using the MinGW Fortran compiler and linker.



-----Original Message-----
From: Eli Zaretskii [mailto:eliz@xxxxxxx] 
Sent: Wednesday, January 18, 2017 10:21 AM
To: Cervinka, Mitch <mitch.cervinka@xxxxxxx>
Cc: mingw-users@xxxxxxxxxxxxxxxxxxxxx
Subject: Re: [Mingw-users] undefined reference to _imp__*

> From: "Cervinka, Mitch" <mitch.cervinka@xxxxxxx>
> CC: "mingw-users@xxxxxxxxxxxxxxxxxxxxx" 
> <mingw-users@xxxxxxxxxxxxxxxxxxxxx>
> Date: Tue, 17 Jan 2017 22:25:35 +0000
> 
> Okay.  Yes, I'm seeing the imp prefixes in the lib file.
> However, the underscores are wrong.
> 
> If I build the import library with DLLTOOL using the --no-leading-underscore option, and then use "nm -A" to examine the file, I see names like ...
> 
>           __imp_SYMBOL1            (i.e. 2 underscores before imp and 1 before the name)
> 
> If I build it without that option, the names look like this ...
> 
>           __imp__SYMBOL1            (i.e. 2 underscores before imp and 2 before the name)
> 
> However, the linker is looking for names like ...
> 
>           _imp__SYMBOL1            (i.e. 1 underscore before imp and two before the name)

No, the linker should look for __imp__SYMBOL1.  That's what I see in the MinGW import libraries, which definitely work.  Are you sure the linker scans your import library?  Adding -v to the link command line should show that.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
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