c++ - 链接器无法找到 __assert_fail

标签 c++ linker

我正在尝试构建一个使用 boost 的库,虽然该库编译正常,但它遇到了一个我不理解的奇怪的链接器错误。我构建并安装了 Boost 1.54(也尝试了 1.52),一切顺利。

它声称无法找到 __assert_fail,我认为它是标准库的一部分。我试图在 64 位中构建所有内容。我在 Fedora 16 上,使用 gcc 4.6.3

有什么想法吗?

make  all-am
make[1]: Entering directory `/data/adrian/code/ext/mapper/cmappertools'
/bin/sh ./libtool  --tag=CXX   --mode=link g++  -g -O2    -o libcmappertools.la -rpath /usr/local/lib/python2.7/site-packages cmappertools.lo  
libtool: link: g++  -fPIC -DPIC -shared -nostdlib /usr/lib/gcc/x86_64-redhat-linux/4.6.3/../../../../lib64/crti.o /usr/lib/gcc/x86_64-redhat-linux/4.6.3/crtbeginS.o  .libs/cmappertools.o   -L/usr/lib/gcc/x86_64-redhat-linux/4.6.3 -L/usr/lib/gcc/x86_64-redhat-linux/4.6.3/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/x86_64-redhat-linux/4.6.3/../../.. -lstdc++ -lm -lc -lgcc_s /usr/lib/gcc/x86_64-redhat-linux/4.6.3/crtendS.o /usr/lib/gcc/x86_64-redhat-linux/4.6.3/../../../../lib64/crtn.o  -O2   -Wl,-soname -Wl,libcmappertools.so.0 -o .libs/libcmappertools.so.0.0.0
.libs/cmappertools.o: In function `condition_variable':
/usr/local/include/boost/thread/pthread/condition_variable_fwd.hpp:69: undefined reference to `__assert_fail'
/usr/local/include/boost/thread/pthread/condition_variable_fwd.hpp:69: undefined reference to `__assert_fail'
.libs/cmappertools.o: In function `~mutex':
/usr/local/include/boost/thread/pthread/mutex.hpp:108: undefined reference to `__assert_fail'
.libs/cmappertools.o: In function `condition_variable':
/usr/local/include/boost/thread/pthread/condition_variable_fwd.hpp:69: undefined reference to `__assert_fail'
.libs/cmappertools.o: In function `~mutex':
/usr/local/include/boost/thread/pthread/mutex.hpp:108: undefined reference to `__assert_fail'
.libs/cmappertools.o:/usr/local/include/boost/smart_ptr/shared_array.hpp:194: more undefined references to `__assert_fail' follow
/usr/local/bin/ld: .libs/libcmappertools.so.0.0.0: hidden symbol `__assert_fail' isn't defined
/usr/local/bin/ld: final link failed: Bad value
collect2: ld returned 1 exit status
make[1]: *** [libcmappertools.la] Error 1
make[1]: Leaving directory `/data/adrian/code/ext/mapper/cmappertools'
make: *** [all] Error 2

最佳答案

几年后,在不同的 Fedora (29)、更高版本的 boost、gcc 等上。我遇到了同样的问题。 更多的是靠直觉而不是理解我摆脱了 gcc visibility pragmas (即我注释掉了所有的: #pragma GCC 可见性推送({whatever}) ... #pragma GCC 可见性弹出) 成功了——编译、链接并成功运行。

关于c++ - 链接器无法找到 __assert_fail,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18165527/

相关文章:

c++ - 如何在 C++/WinRT (`Promise.all` 等效项中等待多个可等待/IAsyncActions)?

c++ - 如何将 C++ 链接到 OpenBlas?

c++ - 从 Swift 调用 C++ 函数

c - 如何确定哪些目标文件实际上是链接所必需的?

c++ - 如何在 C/C++ 中链接两个 .so

c++ - 在没有类声明的情况下使用 Qt 的 Q_DECLARE_FLAGS 和 Q_DECLARE_OPERATORS_FOR_FLAGS

c++ - 如何高效统计定义指针的个数?

c++ - 如何通过信号和槽发送数据?

c - 链接器报告 undefined reference ,但代码编译正常

c++ - 我的 C 文件是由 Pro*C 生成的吗