2015-02-07 35 views
2

我正在構建基於此fast factorial library的代碼,它取決於boost和mpir。我正在運行Ubuntu 14.04並使用Netbeans 8.0.2。爲了簡單的測試庫的#include陳述我做這種無聊的代碼:C++增強錯誤

#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下)不起作用?

+2

您需要鏈接'libboost_system.so'。將'-lboost_system'放入鏈接器標誌中。 – Wintermute 2015-02-07 14:19:34

回答

3

如Wintermute

評論您需要鏈接libboost_system.so。將-lboost_system放入鏈接器標誌中。

解決了這個問題。

+0

沒有足夠的鏈接到** libboost_system.a **嗎?還是它也需要**。so **文件? – 2016-07-18 17:30:34