newprint
newprint

Reputation: 7136

Issues with g++ and Eclipse on Linux - unresolved symbols

I am running Ubuntu 64bit version, and downloaded the latest 64bit Eclipse. Installed g++ along with build-essential. Tested g++ to make sure it works from terminal, and it works fine.

alex@ubuntu:~/Desktop$ g++ test.cpp -o test
alex@ubuntu:~/Desktop$ ./test
Hello World!alex@ubuntu:~/Desktop$ 

However, trying to build simple C++ Hello Word project(one of the default projects that comes with Eclipse), I am getting error.

Description Resource    Path    Location    Type
Program "g++" not found in PATH         Preferences, C++/Build/Settings/Discovery, [CDT GCC Builtin Compiler Settings] options  C/C++ Scanner Discovery Problem

I have added Environment variable named g++ with value /usr/bin/g++ and the above error went away, however, now I am getting unresolved errors, though project compiles and in the Console shows !!!Hello World!!!

Description Resource    Path    Location    Type
Symbol 'endl' could not be resolved test_hello.cpp  /test_hello/src line 13 Semantic Error
Symbol 'cout' could not be resolved test_hello.cpp  /test_hello/src line 13 Semantic Error
Symbol 'std' could not be resolved  test_hello.cpp  /test_hello/src line 10 Semantic Error

Have I correctly entered Environmental variable ?? How can I get fix the "unresolved" error ?? Thanks !

Upvotes: 0

Views: 2896

Answers (1)

Tyler Jandreau
Tyler Jandreau

Reputation: 4335

When compiling there are two important things to consider: 1.) Is my path up-to-date with executables? 2.) Is my library path correct?

It appears you satisfy 1.) but not 2.)

The unresolved symbol error means that Eclipse cannot find your library via LD_LIBRARY_PATH or some other medium. It's attempting to locate the standard compiled C++ library.

How did you install g++?

Kindly do this and post the results:

Project > Properties > C/C++ Build > Environment

If everything there appears nominal, you can try

/sbin/ldconfig

which should hopefully re-parse your system library paths and might update your environment.

Upvotes: 1

Related Questions