我正在试图弄清楚如何设置一些环境变量,这将使g ++链接到正确版本的库.
我在/ usr/lib64中有一些旧的boost库(链接这些将失败)和/ v/users/regel/lib中的新库.因此链接器应链接新库.
命令:
$ g++ test.cpp -lboost_system -L/v/users/regel/lib
Run Code Online (Sandbox Code Playgroud)
正确链接程序.但是,我希望将其设置为链接器的第1个搜索目录,这样我每次链接时都不必指定"-L".
以下环境变量似乎不起作用:
$ LIBRARY_PATH=/v/users/regel/lib g++ test.cpp -lboost_system
/tmp/regel/cc4SmBtI.o: In function `main':
test.cpp:(.text+0x5): undefined reference to `boost::system::system_category()'
collect2: error: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)
和
$ LD_LIBRARY_PATH=/v/users/regel/lib:$LD_LIBRARY_PATH g++ test.cpp -lboost_system
/tmp/regel/ccUreBZy.o: In function `main':
test.cpp:(.text+0x5): undefined reference to `boost::system::system_category()'
collect2: error: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)
尽管阅读了大量关于类似主题的文章和帖子,但我还没有找到解决方案.