0
votes

I figured out how to get the correct and current version of GNU to be the target when compiling.

Now whenever I try to compile.. I get tons of errors that I'm assuming are related to the C++ libraries. I'm currently using NetBeans latest version on my MacBook with the latest install of Mountain Lion.

NetBeans shows a red line under the line:

#include <random>

saying that it cannot find the include file.

I get probably 50 lines of errors. I think it's because it can't detect libraries/headers included in c++? Here's part of the error message

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,

I right clicked the project folder and hit "run" and it gives me this error:

Undefined symbols for architecture x86_64:

"std::__1::basic_string, std::__1::allocator >::compare(char const*) const", referenced from: Ammunition::setElementData(std::__1::basic_string, std::__1::allocator >, std::__1::basic_string, std::__1::allocator >) in Ammunition.o Armor::setElementData(std::__1::basic_string, std::__1::allocator >, std::__1::basic_string, std::__1::allocator >) in 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 >) in 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::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() const", referenced from: _ZNSt3_16vectorIP4ItemNS_9allocatorIS2_EEE6assignIPS2_EENS_9enable_ifIXsr21__is_forward_iteratorIT_EE5valueEvE4typeES9_S9_ in Creature.o std::_1::vector >::allocate(unsigned long) in Creature.o void std::_1::vector, std::__1::allocator >, std::__1::allocator, std::__1::allocator > > >::__push_back_slow_path, std::__1::allocator > const&>(std::__1::basic_string, std::__1::allocator > const&) in Entity.o void std::_1::vector >::_push_back_slow_path(XMLSerializable* const&) in parser.o void std::_1::vector >::_push_back_slow_path(Creature* const&) in CreatureFactory.o std::_1::vector, std::__1::allocator >, std::__1::allocator, std::__1::allocator > > >::allocate(unsigned long) in CreatureFactory.o std::_1::vector >::__append(unsigned long, Tile const&) in DungeonLevel.o ...

Do you know why this is happening? And is it even related to the libraries?

1
Start at the beginning of the error. What's on line 46 of main.cpp?Drew Dormann
It's literally a blank lineHabit
I right clicked the project folder and hit "run" to make sure it was running the correct files. I've added what it said.Habit

1 Answers

0
votes

Your problem is that your function call is wrong.

  1. You are currently calling a version of getline which works with FILE pointers, which is not what you intended. That's the only one the compiler found, based on the headers included.

  2. You are probably trying to extract a line from an input stream, correct? So try this one. Make sure you #include <string>.

  3. Also, you probably don't want to be calling getline on an output stream...

--- Edit ---

The errors you've added look like your library paths are not set correctly... sorry this is hard to fix without having access to the system, hopefully someone else will be able to help you. Good luck.