So my code worked perfectly in Visual Studios but now that I'm testing in Linux I'm getting all types of errors.
This is a preview of my code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
#include <iostream>
#include <ostream>
#include <math.h>
using namespace std;
int main ()
{
..................
return 0;
system("pause");
|
I get the following message when I try to compile:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
dlugo_lab01_v03.cpp:(.text+0x15): undefined reference to `std::cout'
dlugo_lab01_v03.cpp:(.text+0x1a): undefined reference to `std::basic_ostream<cha
r, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basi
c_ostream<char, std::char_traits<char> >&, char const*)'
dlugo_lab01_v03.cpp:(.text+0x26): undefined reference to `std::cin'
dlugo_lab01_v03.cpp:(.text+0x2b): undefined reference to `std::basic_istream<cha
r, std::char_traits<char> >::operator>>(long&)'
dlugo_lab01_v03.cpp:(.text+0x35): undefined reference to `std::cout'
dlugo_lab01_v03.cpp:(.text+0x3a): undefined reference to `std::basic_ostream<cha
r, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basi
c_ostream<char, std::char_traits<char> >&, char const*)'
dlugo_lab01_v03.cpp:(.text+0x46): undefined reference to `std::cin'
dlugo_lab01_v03.cpp:(.text+0x4b): undefined reference to `std::basic_istream<cha
r, std::char_traits<char> >::operator>>(long&)'
dlugo_lab01_v03.cpp:(.text+0x6f): undefined
|
Why is this happening all of a sudden when it works fine in Visual Studios?
EDIT:
Also I forgot to mention that if I leave the system("pause") in it returns:
1 2 3
|
dlugo_lab01_v03.cpp: In function ‘int main()’:
dlugo_lab01_v03.cpp:51: error: ‘system’ was not declared in this scope
[dlugo@1005-11 Desktop]$
|
But if I take it out I get all of that craziness.
Last edited on
Are you compiling with "gcc" or with "g++"?
gcc. My instructor is telling that I need to be able to compile my code in any compiler. I'm even including the following:
1 2 3 4 5 6 7 8
|
#include <iostream>
#include <ostream>
#include <math.h>
#include <stdlib.h>
using namespace std;
|
Last edited on
Yeah but would that cause all that ruckus?
Your errors are cause by using gcc instead of g++.
Yes, this is exactly the problem. I tried to compile using g++ and came up with no errors. Thanks yall.