如何让我的IDE提供C++库

How do I get my IDE to provide the C++ libraries?

本文关键字:提供 C++ IDE 我的      更新时间:2023-10-16

我了解了如何在编译时获得正确的当前版本的GNU。

现在,每当我试图编译。。我得到了大量的错误,我认为这些错误与C++库有关。我目前在我的MacBook上使用NetBeans最新版本,并安装了Mountain Lion。

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::分配器>::compare(char const*(const",引用自:弹药.o中的弹药::setElementDataArmor.o中的Armor::setElementData(std::__1::basic_string,std::_1::allocater>,std:Consumerable.o中的可消费::setElementDataCreature.o中的Creature::setElementData(std::__1::basic_string,std::_1::allocater>,std:实体.o中的实体::setElementData(std::__1::basic_string,std::_1::allocater>,std:Item.o中的项::setElementDataparser.o中的parseElement(std::__1::basic_stream>&,std::_1::vector>&XMLSerializable*(。。。"std::_1::_vector_base_common::__throw_length_error((const",引用自:_ZNSt3_16vectorIP4ItemNS_9allocaterIS2_EEE6assignIPS2_EENS_9enable_ifIXsr21_is_forward_iteratorIT_EE5valueEvE4typeES9_S9_ in Creature.oCreature.o中的std::_1::vector>::allocate(unsigned long(void std::_1::vector,std::__1::allocater>,std:::__1::分配器,std:(std::__1::basic_string,std::___1::allocater>const&(在Entity.o中在解析器.o中无效std::_1::vector>::_push_back_slow_path(XMLSerializable*const&(在CreatureFactory中无效std::_1::vector>::_push_back_slow_path(Creature*const&(。oCreatureFactory中的std::_1::vector,std::__1::allocater>,std:;__1::分配器,std::__1::分配程序>>::分配(无符号长(。ostd::_1::vector>:__append(unsigned long,Tile const&(在DungeonLevel.o中…

你知道为什么会发生这种事吗?它甚至与图书馆有关吗?

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

  1. 您当前正在调用一个使用FILE指针的getline版本,这不是您想要的。这是编译器根据包含的头找到的唯一一个。

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

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

---编辑---

您添加的错误看起来像是您的库路径设置不正确。。。很抱歉,如果没有访问系统的权限,很难解决这个问题,希望其他人能帮助你。祝你好运