c++ - c/c++ boost - 编译问题

标签 c++ c regex boost

我一直在绞尽脑汁想弄清楚如何使用 boost 正则表达式编译我的应用。

我已经在 centos 5 上从源代码安装了 boost。

g++ -lboost_regex -o my_app my_app.c $(mysql_config --libs --cflags)

它编译没有任何错误,但是当我执行它时:

error while loading shared libraries: libboost_regex.so.1.46.1: cannot open shared object file: No such file or directory

该文件的位置是:

/usr/local/lib/libboost_regex.so.1.46.1

有人遇到同样的问题吗?

最佳答案

您是否尝试过 LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH your_program 以确保它知道在哪里可以找到共享对象?您可以在链接时使用-Wl,-R/usr/local/lib设置路径。

编辑:更清楚地说,当您链接代码时,链接器会将 RPATH 和 RUNPATH 嵌入到二进制文件中。这些值告诉运行时加载程序在哪里可以找到所需的共享对象。

如果您将 -Wl,-R/usr/local/lib 添加到您的链接命令,这应该会导致它嵌入该目录并在加载您的程序时始终检查它。

关于c++ - c/c++ boost - 编译问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5421705/

相关文章:

c++ - 用 boost.python 包装一个模板函数

c - c中printf中的多个赋值语句

c - 害怕。寻找。告诉。 "warning: value computed is not used "

java - 使用正则表达式处理换行符 Java

c++ - shm_unlink 的预期行为?

c++ - 将 C++ 代码与 C 代码匹配

c++ - 未定义对符号 '<Symbol>' 的引用 ... 添加符号时出错 : DSO Missing From Command Line (With CMake)

c - 如何将二维动态分配数组传递给函数?

php - 在 strpos() 的字符串中使用正则表达式

javascript - 正则表达式: Understanding non-greedy repetition