2013-04-29 63 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

相关问题