Bug 12987 - Incompatibility with VC++ in -Wl,--out-implib code
Summary: Incompatibility with VC++ in -Wl,--out-implib code
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 3.4.0
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2003-11-10 08:04 UTC by oyvind.harboe
Modified: 2003-11-15 09:02 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2003-11-10 18:44:19


Attachments
First example file (48 bytes, text/plain)
2003-11-10 14:09 UTC, oyvind.harboe
Details
Second example file (48 bytes, text/plain)
2003-11-10 14:09 UTC, oyvind.harboe
Details
If I generate bar.lib from VC++, everything works (510 bytes, application/octet-stream)
2003-11-10 14:48 UTC, oyvind.harboe
Details

Note You need to log in before you can comment on or make changes to this bug.
Description oyvind.harboe 2003-11-10 08:04:10 UTC
This problem is described in:

http://gcc.gnu.org/ml/java/2003-11/msg00055.html

I tried the patch referred to in this thread, and my application links, but it 
crashes when I try to call one of the functions in the DLL.
Comment 1 oyvind.harboe 2003-11-10 08:06:17 UTC
More info:

http://gcc.gnu.org/ml/java/2003-11/msg00112.html
Comment 2 oyvind.harboe 2003-11-10 14:08:00 UTC
This appears to be a more general(not Java specific) compatibility problem 
between Visual C++ 6.0 and GCC. 

I'll attach foo.c and bar.c

1. gcc -shared -o bar.dll -Wl,--out-implib,foo.lib bar.c
2. gcc -o foo foo.c bar.lib

When I compile 2. from VC++, I get an error message and the application crashes 
when it tries to invoke bar():

--------------------Configuration: test2 - Win32 Debug--------------------
Compiling...
foo.c
Linking...
bar.lib(d000001.o) : warning LNK4078: multiple ".text" sections found with 
different attributes (E0000020)

test2.exe - 0 error(s), 1 warning(s)
Comment 3 oyvind.harboe 2003-11-10 14:09:11 UTC
Created attachment 5106 [details]
First example file
Comment 4 oyvind.harboe 2003-11-10 14:09:29 UTC
Created attachment 5107 [details]
Second example file
Comment 5 oyvind.harboe 2003-11-10 14:12:37 UTC
I tested with GCC 3.3 and the VC++ application still crashes when it tries to 
invoke bar().
Comment 6 oyvind.harboe 2003-11-10 14:48:56 UTC
Created attachment 5108 [details]
If I generate bar.lib from VC++, everything works
Comment 7 Andrew Pinski 2003-11-10 18:44:19 UTC
The --out-implib part is not a gcc bug but rather a binutils bug, report it to them also.
Comment 8 Danny Smith 2003-11-10 19:42:11 UTC
This is a known bug in the MS linker: it does not understand  GNU ld import 
libs.

To workaround, build an import lib for MS using a .def file containing the 
exports and the MS programme (I think it is called lib.exe) that does what
GNU dlltool does.

I think that this also applies in general to any other windows linker 
programme. 

Danny
Comment 9 oyvind.harboe 2003-11-10 19:48:03 UTC
>This is a known bug in the MS linker: it does not understand  GNU ld import 
>libs.

Will this be fixed at some point? 

(If not, shouldn't this option be removed from GCC?)

>To workaround, build an import lib for MS using a .def file containing the 
>exports and the MS programme (I think it is called lib.exe) that does what
>GNU dlltool does.

For now I just used GetProcAddress() explicitly, moving on. :-)

Øyvind

Comment 10 Andrew Pinski 2003-11-15 09:02:53 UTC
Not a GCC bug but rather a binutils bug, report it to them.