2011年6月16日 星期四

gcc's -Wl option (ld's -rpath option)

GCC Frequently Asked Questions
http://gcc.gnu.org/faq.html
GCC Frequently Asked Questions: Dynamic linker is unable to find GCC libraries
http://gcc.gnu.org/faq.html#rpath

请教gcc的-rpath选项的意思是什么?
http://www.lslnet.com/linux/dosc1/46/linux-318887.htm

可以去掉啊。用-L就行了,这个其实是ld的选项,我做练习时的一个小例子这么编的:
gcc -Wl,-rpath,/home/arc/test,-rpath,/lib/,-rpath,/usr/lib/,-rpath,/usr/local/lib test.c

Might not be true on dynamic linked library.

gcc的-L选项和-Wl,-rpath,的区别是什么?
http://bbs.chinaunix.net/archiver/?tid-1786166.html

How to build an RPATH into gcc?
http://gcc.gnu.org/ml/gcc/2004-05/msg00275.html
http://gcc.gnu.org/ml/gcc/2004-05/msg00282.html
RPATH is evil (BTW if you really want it, set LDFLAGS='-Wl,-rpath -Wl,/usr/local/lib').

Much better:

# echo /usr/local/lib >> /etc/ld.so.conf
# ldconfig
#

And /lib/ld-linux.so.2 will search libraries there.


Program Library HOWTO
http://www.dwheeler.com/program-library/Program-Library-HOWTO/index.html

Program Library HOWTO
http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html

Re: rpath problems
http://mail.gnome.org/archives/gtk-list/2002-July/msg00043.html
i believe that in general, the use of -rpath as a linker option is deprecated by most people. it will produce a binary that may do
undesirable things on some systems. its preferred to make the "executable" a shell script that sets LD_LIBRARY_PATH and then execs the "real" (binary) executable.

沒有留言: