簡體   English   中英

C ++ Boost錯誤

[英]C++ boost error

我正在基於此快速階乘庫構建代碼,並且它取決於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)所說

您需要鏈接libboost_system.so。 將-lboost_system放在鏈接器標志中。

那解決了問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM