Hi,
I am currently trying to move my application porting environment from Debian unstable to Red Hat 9. I thought this would not be a problem, but I get unexpected linking errors (see below).
I copied the sources (that compile and link fine on the Debian system) to the RedHat 9 environment, which provides gcc 3.2.2 and libc-2.3.2. Furthermore, I installed the latest rpms of 20031016 that are hosted on the sourceforge.net site.
Compiling the sources still works, but linking fails. Here's my example for finally linking all object files together:
gcc -shared -Wl,-Bsymbolic,z,defs -L/usr/lib -L/usr/lib/wine/wine -lm -lc -lwine -lstdc++ -lgcc_s <all object files> -o lib<mydll>.dll.so
On RedHat, however, this fails with the following linker error:
/usr/bin/ld: lib<mydll>.dll.so: undefined versioned symbol name fprintf@@GLIBC_2.0 /usr/bin/ld: failed to set dynamic section sizes: Bad value collect2: ld returned 1 exit status
What I found googling through the net is that these conflicts may be caused due to other libraries that may have been linked with earlier versions (like in this case the striking GLIBC_2.0, which I cannot make any sense of). However, since I only link with Winelib libraries of the latest release, this does not make too much sense to me. Furthermore, I found the advice to interchange the include-sequence of the libraries, but this does not change anything. Furthermore I made sure that I do not carry any old object files with me from previous builds, although I never build against any GLIBC2.0 libaries...
Any help would be appreciated, thanks very much!
Cheers, Martin
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Hi,
just wanted to add that I somehow solved the problem, although I do not have the slightest idea why - please see below. Any explanation on why it now works would help me much to understand the gcc dynamic linking principles.
The problem occured with the following line, which worked perfectly well on my Debian unstable installation (using gcc 3.3.x):
[..] gcc -shared -Wl,-Bsymbolic,z,defs -L/usr/lib -L/usr/lib/wine/wine -lm -lc -lwine -lstdc++ -lgcc_s <all object files> -o lib<mydll>.dll.so
On RedHat 9, however, this failed with the following linker error:
/usr/bin/ld: lib<mydll>.dll.so: undefined versioned symbol name fprintf@@GLIBC_2.0 /usr/bin/ld: failed to set dynamic section sizes: Bad value collect2: ld returned 1 exit status
The first step to resolve this conflict was to omit the linking against standard GNU Linux system libraries, which seems to be done automagically:
gcc -shared -Wl,-Bsymbolic,z,defs -L/usr/lib/wine/wine -lwine -lstdc++ <all object files> -o lib<mydll>.dll.so
This removed versioned dependencies to glibc 2.0, but resulted in similar errors linking against stdc++ (it had undefined versioned symbol names @@GLIBSTDC++_3.2.1).
Omitting -lstdc++ was not possible, causing (as expected) unresolved symbols. The final way to successful linking, however, was switching to g++ to call the linker:
g++ -shared -Wl,-Bsymbolic,z,defs -L/usr/lib/wine/wine -lwine <all object files> -o lib<mydll>.dll.so
Any explanations, wild guesses or whatever to make me understand what may have caused the problem is still appreciated...
Cheers, Martin