Eclipse C++ OpenGL - Cant Build Project - c++

I just installed Eclipse on my new PC (using Mint 17.1) and run into this error with almost every Project so far. The problem is that when I want to launch my project I get the error:
"Launch Failed. Binary not found."
I already tried to Build the project but then I get 2 errors:
./src/main.o: undefined reference to symbol 'glEnable'
make: *** [OpenGL] Fehler 1
Here is the console log:
01:49:45 **** Incremental Build of configuration Debug for project OpenGL ****
make all
Building target: OpenGL
Invoking: GCC C++ Linker
g++ -L/usr/lib/ -L/usr/lib/x86_64-linux-gnu/mesa/ -o "OpenGL" ./src/main.o -lglut -lGLU
/usr/bin/ld: ./src/main.o: undefined reference to symbol 'glEnable'
//usr/lib/x86_64-linux-gnu/mesa/libGL.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make: *** [OpenGL] Fehler 1
01:49:45 Build Finished (took 127ms)
I already searched the web for solutions but I can't seem to find a solution that works.

Based on your error log, you haven't linked -lGL. Try adding it to your libraries in the Linker Settings

Related

Error building mpi2 - trouble linking libboost_system

I am trying to build mpi2 and encounter the following error during make:
/usr/bin/ld: CMakeFiles/env.dir/env.cc.o: undefined reference to symbol '_ZN5boost6system15system_categoryEv'
/usr/local/boost-1.56.0/lib/libboost_system.so: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
The cmake command I used prior to running make was:
cmake -DCMAKE_BUILD_TYPE=NativeRelease ../ -DBOOST_ROOT=/usr/local/boost-1.56.0/ -DBOOST_INCLUDEDIR=/usr/local/boost-1.56.0/include -DBOOST_LIBRARYDIR=/usr/local/boost-1.56.0/lib
I have tried linking against libboost_system.so, but I'm unsure how to do this with cmake (I tried adding -DCMAKE_CXX_FLAGS="-lboost_system" to the cmake command, but this had no effect).
How do I correctly link this with cmake to resolve this error?
I think the problem may be that Boost.System isn't listed as a requirement in the CMakeLists.txt.
Looking at https://github.com/uma-pi1/mpi2/blob/master/CMakeLists.txt#L67, it seems like system should be added immediately after chrono in the find_package(Boost ...) call.

Eclipse C++ MinGW Issue

I'm trying to install the cccfiles library for Eclipse, but I keep getting the following error:
11:24:49 **** Incremental Build of configuration Debug for project Test ****
Info: Internal Builder is used for build
g++ -o Test.exe hello.o practice.o "-lC:\\C++\\cccfiles"
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64 w64-mingw32/bin/ld.exe: cannot find -lC:\C++\cccfiles
collect2.exe: error: ld returned 1 exit status
11:24:49 Build Finished (took 777ms)
I've googled every possible thing I could think of for the last two days and nothing has helped me.

Issue with CMake project building

I have the following problem. On my Ubuntu I try to build a project and receive the following linker error(s) so far:
/usr/bin/ld:
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libboost_thread.a(once.o): undefined reference to symbol 'pthread_once##GLIBC_2.2.5'
/lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO
missing from command line collect2: error: ld returned 1 exit status
make[2]: *** [sunprint] Error 1 make[1]: ***
[CMakeFiles/sunprint.dir/all] Error 2 make: *** [all] Error 2
*** Failure: Exit code 2 ***
I'm running under ubuntu 13 desktop, GCC 4.8, boost ver. is 1.54. As an IDE I'm working with
is the KDevelop.
I can provide any additional info about this issue if needed, but now I'm stuck with
this linking problem.
Any ideas?
Thanx in advance.
add_definitions only adds inputs for the preprocessor, which is in action even before the compiler starts its business and even much farther away from linking the executable, the step ld is supposed to be doing.
What you want to have ld resolve link-time dependencies is the CMake command target_link_libraries, which, for a given target, add a number of libs to link against after compilation.
In you case, the appropriate invocation could look like this
target_link_libraries(${PROJECT_NAME} [...] -lpthread [...]) #obviously without the '[...]' and the correct target name
I had a similar problem but with mpich. Both:
target_link_libraries(${PROJECT_NAME} [...] -lmpich [...])
and
target_link_libraries(${PROJECT_NAME} [...] mpich [...])
worked properly.

Why can't the linker find the CppUnit libraries?

I am trying to learn the CPPUNIT i looked at the following link:
CPPUNIT
although the selected language here is c i have selected c++ while creating this application and have added the
C:\cppunit\cppunit-1.12.1\include to the include directories i have also added cppunitd,cppunit in the linker options however i still the errors as while i try to test the cppunit.
Errors:
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../../mingw32/bin/ld.exe: cannot find
-lcppunitd
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../../mingw32/bin/ld.exe: cannot find -lcppunit
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../../mingw32/bin/ld.exe: cannot find -lcppunit
collect2: ld returned 1 exit status
make[1]: *** [build/Debug/MinGW_1-Windows/tests/TestFiles/f1] Error 1
make: *** [.build-tests-impl] Error 2
BUILD TESTS FAILED (exit value 2, total time: 4s)
Need to use the -L flag and have a path to the library.
I experienced the same linker error and found that I only had 64-bit version of CppUnit installed while building 32-bit application. I solved it by installing 32-bit version of the library.

C++/Eclipse Shared Library: Why can g++ not find this library?

I am following the instructions on
http://tayefeh.wordpress.com/2009/07/06/creating-and-using-a-c-shared-library-with-eclipse-cdt-galileo-and-gnu-c-compiler-and-linker/
to build a shared library.
I have got to Step II, bullet point 16 but my attempts to build the project fail with the following error:
**** Build of configuration Debug for project UseDLL ****
make all
Building target: UseDLL
Invoking: GCC C++ Linker
g++ -L"/home/ken/workspace/testlib/Debug" -o"UseDLL" ./src/UseDLL.o -ltestlib -l/home/ken/workspace/testlib/Debug
/usr/bin/ld: cannot find -l/home/ken/workspace/testlib/Debug
collect2: ld returned 1 exit status
make: *** [UseDLL] Error 1
Can anyone advise why the build is failing? The directory does exist and ls shows
[ken#localhost Debug]$ ls /home/ken/workspace/testlib/Debug/
libtestlib.so TestClass.o
If it helps, I am running CentOS 6.3.
Thanks,
Ken
You should remove this:
-l/home/ken/workspace/testlib/Debug
It makes g++ look for a library of that name.