I can't figure out why this isn't working...
I am working in Linux.
g++
doesn't do anything.
gcc
prints the following:
/tmp/ccyg7NDd.o: In function `main':
test.cc:(.text+0x14): undefined reference to `std::cout'
test.cc:(.text+0x19): 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*)'
test.cc:(.text+0x21): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
test.cc:(.text+0x29): undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))'
/tmp/ccyg7NDd.o: In function `__static_initialization_and_destruction_0(int, int)':
test.cc:(.text+0x51): undefined reference to `std::ios_base::Init::Init()'
test.cc:(.text+0x56): undefined reference to `std::ios_base::Init::~Init()'
/tmp/ccyg7NDd.o:(.eh_frame+0x12): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
Code:
#include <iostream>
#include <stdio.h>
int main(){
std::cout << "test " << std::endl;
return 0;
};
gcc
is the C compiler, you need to useg++
. What do you meang++
does not do anything? You have to execute the compiled binary after you build it (i.e. wheng++
completes). – Wiseman-lstdc++
. – Bremeng++
you want to run the file which, with no other options, is calleda.out
. – Dioramaa.out
, or something else if you gave a-o
option to the compiler; running that should printtest
to the console. – Sangfroid--verbose
flag and it'll tell you more than you want to know. – Emera