如何在构建SimpleAmqpClient项目时避免使用LD_LIBRARY_PATH?

时间:2017-01-27 05:20:44

标签: c++ ld rabbitmq-c

我在文件test.cpp中有以下内容:

#include <SimpleAmqpClient/SimpleAmqpClient.h>

int main() {
    AmqpClient::Channel::ptr_t connection = AmqpClient::Channel::Create("localhost");
}

我可以像这样编译和运行它而不会出现任何问题:

$ g++ test.cpp -o test -l SimpleAmqpClient
$ LD_LIBRARY_PATH=/usr/local/lib/i386-linux-gnu/ ./test

但是,我想这样做而不必设置LD_LIBRARY_PATH

我尝试添加-L /usr/local/lib/i386-linux-gnu无效:

$ g++ test.cpp -o test -l SimpleAmqpClient -L /usr/local/lib/i386-linux-gnu
$ ./test
./test: error while loading shared libraries: librabbitmq.so.4: cannot open shared object file: No such file or directory

避免必须设置LD_LIBRARY_PATH

的好方法是什么?

谢谢!

0 个答案:

没有答案