Red Hat Bugzilla – Bug 18356
Undefined references with libX11.so and egcs++
Last modified: 2008-05-01 11:37:59 EDT
Under RH7.0, some of my old programs do not compile with the new gcc/g++
(2.96), so I installed compat-egcs and compat-egcs++ and dependencies. With
egcs++, however, I get some unresolved symbols in libX11.so (X4).
509) silviu:~/WORK/TOOLS> egcs++ -v
Reading specs from /usr/lib/gcc-lib/i386-glibc21-linux/egcs-2.91.66/specs
gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)
508) silviu:~/WORK/TOOLS> make CC=egcs++ tango
(cd GYPSY; make libgypsy)
make: Entering directory `/home/silviu/WORK.10.4/GYPSY'
ar r libgypsy.a foveate.o grid.o gypsy.o utils.o cblock.o cgrid.o \
mv libgypsy.a /home/silviu/WORK/lib
make: Leaving directory `/home/silviu/WORK.10.4/GYPSY'
(cd PGM; make libpgm)
make: Entering directory `/home/silviu/WORK.10.4/PGM'
ar r libpgm++.a pgm.o fov.o dct.o edge.o blob.o realfft.o clog.o ppm.o
mv libpgm++.a /home/silviu/WORK/lib
make: Leaving directory `/home/silviu/WORK.10.4/PGM'
egcs++ -o tango -g -Wall -L/home/silviu/WORK/lib -L/usr/X11R6/lib -IPGM
-IGYPSY -I/usr/X11R6/include `imlib-config --cflags-gdk` tango.o swin.o
-lX11 -lgypsy -lpgm++
/usr/X11R6/lib/libX11.so: undefined reference to `getpwuid_r@GLIBC_2.1.2'
/usr/X11R6/lib/libX11.so: undefined reference to `shmctl@GLIBC_2.2'
/usr/X11R6/lib/libX11.so: undefined reference to `getpwnam_r@GLIBC_2.1.2'
collect2: ld returned 1 exit status
make: *** [tango] Error 1
All is well if I compile this program with g++-2.96, but then, as I
mentioned above, there are other programs that do not compile with g++.
First of all, I'd be interested in bugzilla reports about apps which
you are not able to build with gcc 2.96 (unless it is an obvious
error in the package, like lyx), best with all relevant details.
Second, if you're using egcs++, then you either have to make
sure -L/usr/lib is on the command line, or -L/usr/i386-glibc21-linux/lib/
is given before -L/usr/X11R6/lib, or compat-libs and compat-glibc
packages are not installed.
The issue is that egcs++ adds -L/usr/i386-glibc21-linux/lib internally
to search path, so that binaries built with it can be run on RH 6.x.
But if libc is picked from that directory (there is a RH 6.x glibc),
you need to make sure libX11 is picked from there as well, because you
cannot mix X11 libraries linked against glibc 2.1.9x with glibc 2.1.3.
Look at kde1 src.rpms in the distribution, they are also compiled
with egcs++ (because KDE1 does not follow C++ standards too closely)
and they make sure the libraries match.