我在文件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
?
谢谢!