开发者

Library search paths using the -R option

There are multitudes of articles online that proclaim in strident tones that the use of LD_LIBRARY_PATH is a bad idea, and that one must set library search paths using the -R option. The majority of said articles also mention Solari开发者_如何学Cs in the same breath. The trouble is, on Linux, this does not work with g++.

g++: unrecognized option '-R'

Now what?


You can use -Wl,-rpath=/your/rpath:

$ g++ -o t t.cpp -Wl,-rpath=/my/lib/dir -lwhatever
$ readelf -a t|grep RPATH
 0x000000000000000f (RPATH)              Library rpath: [/my/lib/dir]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜