简体   繁体   English

C ++ Boost错误

[英]C++ boost error

I'm building a code based on this fast factorial library , and it depends on boost and mpir. 我正在基于此快速阶乘库构建代码,并且它取决于boost和mpir。 I'm running Ubuntu 14.04 and using Netbeans 8.0.2. 我正在运行Ubuntu 14.04,并使用Netbeans 8.0.2。 To simply test the #include statements of the library I made this silly code: 为了简单地测试库的#include语句,我做了以下愚蠢的代码:

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

When I try to compile it however I get the following error 当我尝试编译它时,出现以下错误

"/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)

Can anyone help me with why is the boost library (which is installed and present under /usr/include) is not working? 谁能帮我解决为什么boost库(已安装并在/ usr / include下存在)不能正常工作的问题?

As commented by Wintermute 正如温特姆特(Wintermute)所说

You need to link libboost_system.so. 您需要链接libboost_system.so。 Put -lboost_system in your linker flags. 将-lboost_system放在链接器标志中。

That solved the problem. 那解决了问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM