Re: Linux, X, ld, gcc, linking, shared libraries and stuff



Frank Kotler wrote:
>
> Apparently, we need to tell ld the "Interpreter" ("-I") or
> "--dynamic-linker" to use - "-I" is shorter :)
>
> ld -s -o example2 example2.o -I /lib/ld-linux.so.2 -lX11
> -L/usr/X11R6/lib
>
> Works cherry for me!

That is odd.  GNU ld on FreeBSD knows all about the dynamic
linker without being told.  I am very surprised that GNU ld on
Linux is not that smart.  Are you sure that is the real problem?
Try linking the program without specifying the dynamic linker,
and use objdump or whatever to look at the .interp section.  If
that is correct, then specifying the dynamic linker is just
masking the real problem.

You might want to try seeing if the problem occurs when you use libc only, not the X libraries.

It is also possible that there is some problem with the installation of ld. Dynamic linking requires some configuration; hints files, default library paths, and the like. It is conceivable that something along those lines is wrong that has not been discovered because so few people call ld directly.

I would also urge you to use the C startup and cleanup code if
you are linking to C libraries. That code exists for a reason; some library functions depend on it.


--
Thomas M. Sommers -- tms@xxxxxx -- AB2SB



.



Relevant Pages

  • FreeBSD 5.1 BETA 2 make cvsup-without-gui fails
    ... checking if the linker is GNU ld... ... checking whether the linker supports shared libraries... ... checking if libtool supports shared libraries... ...
    (freebsd-current)
  • /ports/multimedia/gstreamer-plugins80/ fails
    ... checking for C compiler default output file name... ... checking whether we are using the GNU C compiler... ... checking whether the cc linker supports shared libraries... ...
    (freebsd-questions)
  • gstreamer-plugins80 compile fails
    ... checking for C compiler default output file name... ... checking whether we are using the GNU C compiler... ... checking whether the cc linker supports shared libraries... ...
    (freebsd-questions)
  • Install problem with js
    ... checking for gcc... ... checking whether we are using the GNU C compiler... ... checking whether the gcc linker supports shared libraries... ...
    (alt.os.linux.suse)
  • Re: Defining many classes in a single file
    ... And one can declare just as many in a header file. ... Another reason for one class one file is due to linker ... smallest resolution. ... In this case, you can have libraries. ...
    (comp.lang.cpp)