6 Replies - 1006 Views - Last Post: 22 June 2012 - 02:13 PM Rate Topic: -----

#1 natecat  Icon User is offline

  • D.I.C Head

Reputation: 47
  • View blog
  • Posts: 209
  • Joined: 19-December 11

Eclipse for C++/C developers acting weird.

Posted 21 June 2012 - 04:38 PM

I just downloaded eclipse for C++/C developers, and created a new hello world project to test that everything is installed right. The hello world program came up with a few errors: Symbol 'cout' could not be resolved, Symbol 'endl' could not be resolved, Symbol 'std' could not be resolved. Does C++ require something like java's JDK in order to compile?
Is This A Good Question/Topic? 0
  • +

Replies To: Eclipse for C++/C developers acting weird.

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 5722
  • View blog
  • Posts: 22,632
  • Joined: 23-August 08

Re: Eclipse for C++/C developers acting weird.

Posted 21 June 2012 - 04:44 PM

Do you have using namespace std; in your code?
Was This Post Helpful? 0
  • +
  • -

#3 natecat  Icon User is offline

  • D.I.C Head

Reputation: 47
  • View blog
  • Posts: 209
  • Joined: 19-December 11

Re: Eclipse for C++/C developers acting weird.

Posted 21 June 2012 - 04:48 PM

Yes, but that itself is throwing a error.
Was This Post Helpful? 0
  • +
  • -

#4 snoopy11  Icon User is offline

  • Engineering ● Software
  • member icon

Reputation: 495
  • View blog
  • Posts: 1,546
  • Joined: 20-March 10

Re: Eclipse for C++/C developers acting weird.

Posted 21 June 2012 - 09:52 PM

Hi,

Have you included the header <iostream>

at the top of the program ?

#include <iostream>

Snoopy.
Was This Post Helpful? 0
  • +
  • -

#5 Salem_c  Icon User is offline

  • void main'ers are DOOMED
  • member icon

Reputation: 1418
  • View blog
  • Posts: 2,681
  • Joined: 30-May 10

Re: Eclipse for C++/C developers acting weird.

Posted 21 June 2012 - 10:09 PM

My guess is you used

gcc foo.cpp

rather than

g++ foo.cpp


You need to use a C++ compiler to compile C++ code.

$ gcc foo.cpp
/tmp/ccLqikjD.o: In function `fun(int const&)':
foo.cpp:(.text+0x54): undefined reference to `std::cout'
foo.cpp:(.text+0x59): undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(int)'
foo.cpp:(.text+0x66): 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)'
/tmp/ccLqikjD.o: In function `__static_initialization_and_destruction_0(int, int)':
foo.cpp:(.text+0x8f): undefined reference to `std::ios_base::Init::Init()'
foo.cpp:(.text+0x94): undefined reference to `std::ios_base::Init::~Init()'
/tmp/ccLqikjD.o:(.eh_frame+0x12): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
$ g++ foo.cpp
$ gcc -c foo.cpp


Whilst you can COMPILE C++ code by invoking gcc, it does not pass all the correct options on to the linker (hence all the undefined reference errors). You need g++ in order to compile AND link.
Was This Post Helpful? 0
  • +
  • -

#6 natecat  Icon User is offline

  • D.I.C Head

Reputation: 47
  • View blog
  • Posts: 209
  • Joined: 19-December 11

Re: Eclipse for C++/C developers acting weird.

Posted 22 June 2012 - 01:03 PM

Ok guys, First of all, this is autogenerated code. There is no mistakes in it, ok? Second I am using eclipse, not the console
Was This Post Helpful? 0
  • +
  • -

#7 jimblumberg  Icon User is offline

  • member icon

Reputation: 3110
  • View blog
  • Posts: 9,479
  • Joined: 25-December 09

Re: Eclipse for C++/C developers acting weird.

Posted 22 June 2012 - 02:13 PM

Quote

Does C++ require something like java's JDK in order to compile?

Yes it requires a compiler like gcc.

What is the complete name of the file you are trying to compile. I don't remember if you can compile a file, in Eclipse, without first creating a project but I recommend you create a project and add files to your project. Also you may need to inform Eclipse where the compiler is located. I am not familiar enough with this IDE to say exactly how to properly set up the build environment.

Jim
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1