如何让IDE提供C ++库?

时间:2013-04-29 04:02:26

标签: c++ netbeans ide gnu

我想出了如何在编译时将正确和当前版本的GNU作为目标。

现在每当我尝试编译时......我都会遇到很多错误,我认为这些错误与C ++库有关。我目前正在使用最新安装的Mountain Lion在我的MacBook上使用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,std :: __ 1 :: allocator&gt; :: compare(char const *)const”,引自:       Ammunition.o中的Ammunition :: setElementData(std :: __ 1 :: basic_string,std :: __ 1 :: allocator&gt;,std :: __ 1 :: basic_string,std :: __ 1 :: allocator&gt;)       Armor.o中的Armor :: setElementData(std :: __ 1 :: basic_string,std :: __ 1 :: allocator&gt;,std :: __ 1 :: basic_string,std :: __ 1 :: allocator&gt;)       Consumable ::o Consumable :: setElementData(std :: __ 1 :: basic_string,std :: __ 1 :: allocator&gt;,std :: __ 1 :: basic_string,std :: __ 1 :: allocator&gt;)       在Creature.o中的Creature :: setElementData(std :: __ 1 :: basic_string,std :: __ 1 :: allocator&gt;,std :: __ 1 :: basic_string,std :: __ 1 :: allocator&gt;)       Entity.o中的Entity :: setElementData(std :: __ 1 :: basic_string,std :: __ 1 :: allocator&gt;,std :: __ 1 :: basic_string,std :: __ 1 :: allocator&gt;)       Item.o中的Item :: setElementData(std :: __ 1 :: basic_string,std :: __ 1 :: allocator&gt;,std :: __ 1 :: basic_string,std :: __ 1 :: allocator&gt;)       parser.o中的parseElement(std :: __ 1 :: basic_istream&gt;&amp;,std :: __ 1 :: vector&gt;&amp;,XMLSerializable *)       ...    “std :: _ 1 :: _vector_base_common :: __ throw_length_error()const”,引自:       在Creature.o中_ _ em> ZNSt3 _16vectorIP4ItemNS_9allocatorIS2_EEE6assignIPS2_EENS_9enable_ifIXsr21__is_forward_iteratorIT_EE5valueEvE4typeES9_S9_       在Creature.o中的std :: _ 1 :: vector&gt; :: allocate(unsigned long)       void std :: _1 :: vector,std :: __ 1 :: allocator&gt ;,std :: __ 1 :: allocator,std :: __ 1 :: allocator&gt; &GT; &gt; :: __ push_back_slow_path,std :: __ 1 :: allocator&gt; Entity.o中的const&amp;&gt;(std :: __ 1 :: basic_string,std :: __ 1 :: allocator&gt; const&amp;)       parser.o中的void std :: _ 1 :: vector&gt; :: _push_back_slow_path(XMLSerializable * const&amp;)       CreatureFactory.o中的void std :: _ 1 :: vector&gt; :: _push_back_slow_path(Creature * const&amp;)        std :: _ 1 :: vector,std :: __ 1 :: allocator&gt;,std :: __ 1 :: allocator,std :: __ 1 :: allocator&gt; &GT; &gt; ::在CreatureFactory.o中分配(unsigned long)       DungeonLevel.o中的std :: _1 :: vector&gt; :: __ append(unsigned long,Tile const&amp;)       ...

你知道为什么会这样吗?它甚至与图书馆有关吗?

1 个答案:

答案 0 :(得分:0)

您的问题是您的函数调用错误。

  1. 您目前正在调用getline版本,该版本适用于FILE指针,这不是您的意图。这是编译器找到的唯一一个,基于包含的头文件。

  2. 您可能正在尝试从输入流中提取一行,对吗?所以试试this one。确保#include <string>

  3. 此外,您可能不希望在输出流上调用getline ...

  4. ---编辑---

    您添加的错误看起来像您的库路径未正确设置...抱歉,如果没有访问系统很难修复,希望其他人能够帮助您。祝你好运。