[Gllug] library includes and compiling

Nix nix at esperi.demon.co.uk
Sat Jan 12 20:28:50 UTC 2002


On Thu, 10 Jan 2002, tet at accucard.com yowled:
> 
>>yuck. ITYM
>>
>>gcc -O2 -Wall -ansi -pedantic -o source source.c -L/usr/X11R6/lib -lGL
> 
> If you're doing that, you might as well go the whole hog and add:
> 
> 	-pedantic-errors -Wl,-rpath /usr/X11R6/lib

-rpath is a bad idea on systems running the GNU libc, because it bans
you from moving those shared libraries around. If you leave out the
-rpath, the ld.so.cache and ld.so.conf are consulted, so the libraries
can move freely as long as the ld.so.conf is kept up to date; if you
include -rpath, the program simply breaks if the X libraries ever move,
and you must relink.

> The latter option is probably a good idea anyway. I just wish their was

It is a very bad idea.

> a way to get the linker to automatically add a directory to the run path
> if it links a library from that directory. The Solaris linker does this
> (or used to -- it's been many years since I've used it).

The Solaris linker does this because Solaris does not support
/etc/ld.so.conf, so it has no dynamic site-wide shared library path
scheme. The GNU linker doesn't do it, and shouldn't.

(You can *make* it do it with the specs-file hack, but, well, no. -rpath
has no advantages and one compelling disadvantage on GNU libc systems.)

> Oh, and while I'm at it, -Wl? What muppet thought to use -W for that
> where everywhere else in gcc, it's used to enable/disable warnings

That's not the worst of the inconsistent switches; -pthreads, or is it
-threads, or is it -pthread (depending on target architecture!) is the
worst.

*sick*

-- 
`Perhaps you should have asked Santa for your program as a Christmas
present.' --- Terran Melconian

-- 
Gllug mailing list  -  Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug




More information about the GLLUG mailing list