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.
To build with just cmake change directory into where you want the binaries to be placed. For an in-place build you then run cmake and it will produce a CMakeCache. txt file that contains build options that you can adjust using any text editor.
CMake is a meta build system that uses scripts called CMakeLists to generate build files for a specific environment (for example, makefiles on Unix machines). When you create a new CMake project in CLion, a CMakeLists. txt file is automatically generated under the project root.
There are more than 25 alternatives to CMake for a variety of platforms, including Linux, Mac, Windows, BSD and Xcode. The best alternative is GNU Make, which is both free and Open Source. Other great apps like CMake are Maven, Premake, SCons and Ninja Build.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With