My c++ program was giving e errors when I tried to compile so I fixed them all, but then it gave me a completely different set of errors about undefined references. Here's the code for armyGame.cpp:
#include <iostream>
int main(int argc, char **argv)
{
int players;
std::cout << "Please enter the number of players, between 2 and 6:";
std::cin >> players;
switch (players) {
case 1:
std::cout << "Invalid input. Try again.";
return 18;
case 2:
int p12, p22;
case 3:
int p13, p23, p33;
case 4:
int p14, p24, p34, p44;
case 5:
int p15, p25, p35, p45, p55;
case 6:
int p16, p26, p36, p46, p56, p66;
}
}
Here's my input to gcc:
gcc armyGame.cpp
And here's the error message:
/usr/bin/ld: /tmp/cc3SlY1r.o: in function `main':
armyGame.cpp:(.text+0x15): undefined reference to `std::cout'
/usr/bin/ld: armyGame.cpp:(.text+0x1a): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/usr/bin/ld: armyGame.cpp:(.text+0x26): undefined reference to `std::cin'
/usr/bin/ld: armyGame.cpp:(.text+0x2b): undefined reference to `std::istream::operator>>(int&)'
/usr/bin/ld: armyGame.cpp:(.text+0x3d): undefined reference to `std::cout'
/usr/bin/ld: armyGame.cpp:(.text+0x42): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/usr/bin/ld: /tmp/cc3SlY1r.o: in function `__static_initialization_and_destruction_0(int, int)':
armyGame.cpp:(.text+0x77): undefined reference to `std::ios_base::Init::Init()'
/usr/bin/ld: armyGame.cpp:(.text+0x86): undefined reference to `std::ios_base::Init::~Init()'
collect2: error: ld returned 1 exit status
Any guesses?