2013-04-29 37 views
0

我想出瞭如何在編譯時讓GNU的正確和當前版本成爲目標。如何讓我的IDE提供C++庫?

現在每當我嘗試編譯..我得到噸,我假設與C++庫有關的錯誤。我目前在我的MacBook上使用最新版本的Mountain Lion上的NetBeans最新版本。

的NetBeans顯示了線下一條紅線:

#include <random> 

說,它無法找到包含文件。

我可能會收到50行錯誤。我認爲這是因爲它無法檢測C++中包含的庫/頭文件?下面是錯誤消息的一部分

main.cpp:46:31: error: no matching function for call to 'getline(std::ofstream&)' 
main.cpp:46:31: note: candidates are: 
In file included from /usr/include/wchar.h:114:0, 
      from /opt/local/include/gcc47/c++/cwchar:46, 
      from /opt/local/include/gcc47/c++/bits/postypes.h:42, 
      from /opt/local/include/gcc47/c++/iosfwd:42, 
      from /opt/local/include/gcc47/c++/ios:39, 
      from /opt/local/include/gcc47/c++/ostream:40, 
      from /opt/local/include/gcc47/c++/iostream:40, 
      from main.cpp:9: 
/usr/include/stdio.h:449:9: note: ssize_t getline(char**, size_t*, FILE*) 
/usr/include/stdio.h:449:9: note: candidate expects 3 arguments, 1 provided 
In file included from /opt/local/include/gcc47/c++/string:54:0, 

我右鍵單擊項目文件夾,然後點擊 「運行」,這讓我這個錯誤:

Undefined symbols for architecture x86_64: 

「的std :: __ 1 :: basic_string的,性病:: __1 :: basic_string,std :: __ 1 :: allocator>,std :: __ 1 :: basic_string,__1 :: allocator> :: compare(char const *)const「,引用來自: Ammunition :: setElementData(std :: __ 1 :: basic_string, std :: __ 1 :: basic_string,std :: __ 1 :: allocator>,std :: __ 1 :: basic_string,std :: __ 1 :: std :: std :: std :: std :: std :: std :: std :: std :: std :: std :: std :: std :: _d ::分配器>)在Armor.o Consumable :: setElementData(std :: __ 1 :: basic_string,std :: __ 1 :: allocator>,std :: __ 1 :: basic_string,std :: __ 1 :: allocator>)in Consumable.o Creature :: setElementData( std :: __ 1 :: basic_string,std :: __ 1 :: allocator>,std :: __ 1 :: basic_string,std :: __ 1 :: allocator>)在Creature.o中 Entity :: setElementData(std :: __ 1 :: basic_string,std :: __ 1 :: allocator>,std :: __ 1 :: basic_string,std :: __ 1 :: allocator>)in Entity.o Item :: setElementData(std :: __ 1 :: basic_string,std :: __ 1 :: stdio :: :: allocator>,std :: __ 1 :: basic_string,std :: __ 1 :: allocator>)in Item.o parseElement(std :: __ 1 :: basic_istream> &,std :: __ 1 :: vector> &,XMLSerializable *)in parser.o ... 「std :: _ 1 :: _vector_base_common :: __ throw_length_error()常量」,從引用:在Creature.o 的std :: _ 1 ::矢量> _ ZNSt3 _16vectorIP4ItemNS_9allocatorIS2_EEE6assignIPS2_EENS_9enable_ifIXsr21__is_forward_iteratorIT_EE5valueEvE4typeES9_S9_ ::分配(無符號長整數)在Creature.o 空隙的std :: _1 ::向量,標準:: __ 1 :: allocator>,std :: __ 1 :: allocator,std :: __ 1 :: allocator>>> :: __ push_back_slow_path,std :: __ 1 :: allocator> const &>(std :: __ 1 :: basic_string,的std :: __ 1 ::分配器>在Entity.o常量&) 空隙的std :: _ 1 ::矢量> :: _push_back_slow_path(XMLSerializable *在parser.o常量&) 空隙的std :: _ 1 :: vector> :: _push_back_slow_path(Creature * const &)in CreatureFactory.o std :: _ 1 :: vector,std :: __ 1 :: allocator>,std :: __ 1 :: allocator,std :: __1 ::分配器>>> ::分配(無符號長整數)在CreatureFactory.o 的std :: _1 ::矢量> :: __追加(無符號長,瓷磚常量&)在DungeonLevel.o ...

你知道這是爲什麼發生嗎?它甚至與圖書館有關嗎?

+0

從錯誤開始處開始。 main.cpp的第46行是什麼? – 2013-04-29 04:07:08

+0

這實際上是一個空行 – Habit 2013-04-29 04:10:07

+0

我右鍵單擊項目文件夾,並點擊「運行」,以確保它運行正確的文件。我已經添加了它所說的內容。 – Habit 2013-04-29 04:11:40

回答

0

你的問題是你的函數調用是錯誤的。

  1. 您正在調用一個版本的getlineFILE指針的作品,這是不是你預期什麼。這是編譯器根據所包含頭文件找到的唯一一個。

  2. 您可能試圖從輸入流中提取一行,是否正確?所以請嘗試this one。確保你#include <string>。您添加

  3. 而且,你可能不希望被調用輸出流上getline ...

---編輯---

的錯誤的樣子你的圖書館路徑設置不正確......對不起,如果沒有系統訪問權限,很難修復,希望其他人能夠幫助你。祝你好運。

+0

那條線是空的,哈哈,我發誓。我只是將相同的代碼上傳到我的學校SSH,它編譯並運行得很好。我不明白它如何在服務器上百分百地運行,但是當我下載相同的代碼狀態時,我得到了不間斷的錯誤 – Habit 2013-04-29 04:22:32

+0

我很幸運,運行終端命令顯示我的隱藏文件後,發現舊的目錄擁有所有的庫和插件等。所以我只複製了所有的新文件,選擇覆蓋舊文件,並將編譯器路徑設置回原來的樣子。現在唯一的問題是我的makefile如何編譯/鏈接所有東西。我很親密! – Habit 2013-04-29 05:58:50

+1

繼續吧!那麼您將能夠回答其他人關於NetBeans的問題:-) – 2013-04-29 06:38:07

相關問題