C++ boost 错误

标签 c++ linux boost build

我正在基于此构建代码 fast factorial library ,并且取决于 boost 和 mpir 。我正在运行 Ubuntu 14.04 并使用 Netbeans 8.0.2。为了简单地测试库的#include语句,我编写了这个愚蠢的代码:

#include <iostream>
#include <mpir.h>
#include <primeswing.h>
#include <xmath.h>
 /*
 * 
 */
int main() {
    long x = 4;
    std::cout << x;
    return 0;
}

当我尝试编译它时,出现以下错误

"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `/home/arengorn/NetBeansProjects/BA'
"/usr/bin/make"  -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux-x86/ba
make[2]: Entering directory `/home/arengorn/NetBeansProjects/BA'
mkdir -p dist/Debug/GNU-Linux-x86
g++     -o dist/Debug/GNU-Linux-x86/ba build/Debug/GNU-Linux-x86/main.o ->lm
build/Debug/GNU-Linux-x86/main.o: In function `__static_initialization_and_destruction_0':
/usr/include/boost/system/error_code.hpp:222: undefined reference to `boost::system::generic_category()'
/usr/include/boost/system/error_code.hpp:223: undefined reference to `boost::system::generic_category()'
/usr/include/boost/system/error_code.hpp:224: undefined reference to `boost::system::system_category()'
collect2: error: ld returned 1 exit status
make[2]: *** [dist/Debug/GNU-Linux-x86/ba] Error 1
make[2]: Leaving directory `/home/arengorn/NetBeansProjects/BA'
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory `/home/arengorn/NetBeansProjects/BA'
make: *** [.build-impl] Error 2

BUILD FAILED (exit value 2, total time: 114ms)

任何人都可以帮我解决为什么 boost 库(安装并存在于/usr/include 下)无法工作吗?

最佳答案

正如 Wintermute 所评论

You need to link libboost_system.so. Put -lboost_system in your linker flags.

问题解决了。

关于C++ boost 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28383167/

相关文章:

c++ - 模板的隐式特化是什么意思?

c++ - Visual Studio 中的嵌套 lambda

使用 valgrind 进行分块矩阵乘法的 C++ 性能分析

c++ - X11 窗口不会自动更新/绘图

linux - 在 bash 进程替换完成输入后,如何继续发送到标准输入?

php - scanimage 和 shell_exec ...可能吗?

c++ - 如何使用 QT 在 Linux 上正确显示 unicode 符号?

c++ - CLion 中 CMake 的引用 boost

c++ - Boost asio 与标准输入混淆?

c++ - 使用 Boost Spirit Qi 解析分隔的 token 列表