c++ - 为 ubuntu 和 libboost_date_time boost 1.49

标签 c++ boost

我刚刚在ubuntu上安装了boost 1.49版本,过程很顺利。然而,现在当我运行我的任何文件时(因此我没有发布 c++ 文件,因为它发生在每个使用 libboost_date_time 的文件中),我收到以下错误:

./test.shared.array.exe: error while loading shared libraries: libboost_date_time.so.1.49.0: cannot open shared object file: No such file or directory

我检查了 boost.build 安装库的位置,我在 /usr/local/ 中看到了 libboost_date_time.so.1.49.0

为什么我会得到这样的错误。我该如何解决这个问题。

这些是 /usr/local/boost_1_49_0 的内容

/usr/local/boost_1_49_0$ ls
b2      boost-build.jam  bootstrap.bat  index.htm   libs                rst.css
bin.v2  boostcpp.jam     bootstrap.log  index.html  LICENSE_1_0.txt     status
bjam    boost.css        bootstrap.sh   INSTALL     more                tools
boost   boost.png        doc            Jamroot     project-config.jam

这就是我所拥有的

/usr/local/lib$ ls
libboost_chrono.a              libboost_prg_exec_monitor.so.1.49.0
libboost_chrono.so             libboost_program_options.a
libboost_chrono.so.1.49.0      libboost_program_options.so
libboost_date_time.a           libboost_program_options.so.1.49.0
libboost_date_time.so          libboost_random.a
libboost_date_time.so.1.49.0   libboost_random.so
libboost_exception.a           libboost_random.so.1.49.0
libboost_filesystem.a          libboost_regex.a
libboost_filesystem.so         libboost_regex.so
libboost_filesystem.so.1.49.0  libboost_regex.so.1.49.0
libboost_graph.a               libboost_serialization.a
libboost_graph.so              libboost_serialization.so
libboost_graph.so.1.49.0       libboost_serialization.so.1.49.0
libboost_iostreams.a           libboost_signals.a
libboost_iostreams.so          libboost_signals.so
libboost_iostreams.so.1.49.0   libboost_signals.so.1.49.0
libboost_locale.a              libboost_system.a
libboost_locale.so             libboost_system.so
libboost_locale.so.1.49.0      libboost_system.so.1.49.0
libboost_math_c99.a            libboost_test_exec_monitor.a
libboost_math_c99f.a           libboost_thread.a
libboost_math_c99f.so          libboost_thread.so
libboost_math_c99f.so.1.49.0   libboost_thread.so.1.49.0
libboost_math_c99l.a           libboost_timer.a
libboost_math_c99l.so          libboost_timer.so
libboost_math_c99l.so.1.49.0   libboost_timer.so.1.49.0
libboost_math_c99.so           libboost_unit_test_framework.a
libboost_math_c99.so.1.49.0    libboost_unit_test_framework.so
libboost_math_tr1.a            libboost_unit_test_framework.so.1.49.0
libboost_math_tr1f.a           libboost_wave.a
libboost_math_tr1f.so          libboost_wave.so
libboost_math_tr1f.so.1.49.0   libboost_wave.so.1.49.0
libboost_math_tr1l.a           libboost_wserialization.a
libboost_math_tr1l.so          libboost_wserialization.so
libboost_math_tr1l.so.1.49.0   libboost_wserialization.so.1.49.0
libboost_math_tr1.so           ocaml
libboost_math_tr1.so.1.49.0    perl
libboost_prg_exec_monitor.a    python2.7
libboost_prg_exec_monitor.so   R

最佳答案

您的系统可能不会在此路径中查找 .so。

检查/etc/ld.so.conf 以查看在哪些目录中搜索 so。 /usr/local 对于那些要安装的位置来说是一个奇怪的位置。我期望/usr/lib 或/usr/local/lib。

[编辑以反射(reflect)新信息]

因为你已经在/usr/local/lib 中安装了 boost(我假设所有的 .so 都在下面)并且这个路径已经在 /etc/ld.so.conf.d 你可以尝试运行 ldconfig:

sudo ldconfig

确保您使用正确的库进行编译,例如:

gcc test.shared.array.cpp -lboost_date_time

关于c++ - 为 ubuntu 和 libboost_date_time boost 1.49,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9865971/

相关文章:

c++ - 添加索引为 -2 的整数

c++ - 在 Qt 中制作所见即所得

c++ - 从非常大的文件中解析每四行的最有效方法

c++ - 使用 lambda 的 boost::io_service post

c++ - boost::multi_index_container 因 _com_ptr_t 对象而崩溃

c++ - boost 属性树 : Where have my escape sequences gone in JSON String?

c++ - std::lock_guard 在 openmp 并行

c++ - 格式化 IO 函数 (*printf/*scanf) 中的转换说明符 %i 和 %d 有什么区别

c++ - 如何在 UML 中表示 C++ 的嵌套类?

c++ - 与 boost::mpl 占位符评估不一致的行为