0

我在文件中有以下内容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

谢谢!

4

0 回答 0