【发布时间】:2014-05-04 19:38:59
【问题描述】:
我有一个使用boost::asio 的非常基本的客户端/服务器项目。它生成两个可执行文件,一个客户端和一个服务器。
当我运行客户端时,我得到以下信息:
./client: error while loading shared libraries:
libboost_system.so.1.55.0: cannot open shared object
file: No such file or directory
这意味着程序需要在运行时动态加载boost_system 二进制文件。这是有道理的,因为boost_asio 的一个依赖项是boost_system。
这对于将我的应用程序轻松分发给最终用户意味着什么?
1) 我是否只是在我的系统上弹出我的开发版本的boost_system 二进制文件,在这种情况下是libboost_system.so.1.55.0?我如何确保当用户运行客户端时,它会找到动态存档?显然,在我的系统上,即使我安装了 boost,它仍然找不到存档。
2) 我在 Linux 上构建,因此我有 .so 二进制文件。如果我尝试使用 mingw-w64 交叉编译适用于 Windows 的应用程序,#1 将如何变化?
我是分发 C++ 程序和使用动态/共享库的新手。
当我静态编译时,我收到以下警告:
Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
【问题讨论】:
-
您可以使用静态库版本(
.a)来避免外部依赖。也许你必须用一些参数重新编译 boost 才能得到它们。 -
当我静态链接时,我得到
Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking -
这是 ant 生成的:g++ -fexceptions -pthread -std=c++11 -o build/debug/client /eclipse/cppplay/build/debug/obj/client/Client.o -static -I/usr/local/bin/boost -L/usr/local/bin/boost/lib -lboost_system -g
-
也许this 可以帮助你。我以前从未遇到过这个警告。
-
我已经看到了这个问题。不幸的是,帖子中没有很好的答案。