22

I am following this thread and this one to build my own KDE without a sudo permission. Since there was no Git and CMake installed on the workstation. I just had them both installed under /home/< user> and added /home/< user>/bin and /home/< user>/lib to both PATH and LD_LIBRARY_PATH. Since KDE build only supports CMake, not configure. So I have to set the prefix via CMake, like this: cmake ~/kde-devel/src/kdelibs -DCMAKE_INSTALL_PREFIX=/home/<user>. At this point I got below error:

> ~/bin/cmake ~/kde-devel/src/kdelibs -DCMAKE_INSTALL_PREFIX=/home/<user>
-- The CXX compiler identification is unknown
-- Check for working CXX compiler: /home/gnu/bin/c++
-- Check for working CXX compiler: /home/gnu/bin/c++ -- broken
CMake Error at /home/<user>/share/cmake-2.8/Modules/CMakeTestCXXCompiler.cmake:45 (MESSAGE):
  The C++ compiler "/home/gnu/bin/c++" is not able to compile a simple test
  program.

  It fails with the following output:

   Change Dir: /home/<user>/kde-devel/build/kdelibs/CMakeFiles/CMakeTmp



  Run Build Command:/usr/bin/gmake "cmTryCompileExec/fast"
  ...

I checked that there are 2 C++ compilers:

> where c++
/home/gnu/bin/c++
/usr/bin/c++

Should I set CMake default C++ compiler to /usr/bin/c++? and how? Or is there any way to fix this issue?

Community
  • 1
  • 1
Stan
  • 37,207
  • 50
  • 124
  • 185

3 Answers3

58

Run apt-get install build-essential on your system.

This package depends on other packages considered to be essential for builds and will install them. If you find you have to build packages, this can be helpful to avoid piecemeal resolution of dependencies.

See this page for more info.

David Ferenczy Rogožan
  • 23,966
  • 9
  • 79
  • 68
Ramzes
  • 751
  • 1
  • 6
  • 3
24

Your /home/gnu/bin/c++ seem to require additional flag to link things properly and CMake doesn't know about that.

To use /usr/bin/c++ as your compiler run cmake with -DCMAKE_CXX_COMPILER=/usr/bin/c++.

Also, CMAKE_PREFIX_PATH variable sets destination dir where your project' files should be installed. It has nothing to do with CMake installation prefix and CMake itself already know this.

John Zwinck
  • 239,568
  • 38
  • 324
  • 436
arrowd
  • 33,231
  • 8
  • 79
  • 110
  • 2
    `-DCMAKE_CXX_COMPILER=/usr/bin/c+`+ solved my problem on windows 10 bash shell. I was facing this problem when installing 'Emscripten' for WebAssembly – TechMaze Aug 04 '17 at 05:50
  • If you need to config also "-DCMAKE_C_COMPILER=" you will need to add "/usr/bin/gcc" – Alberto Tono Jul 06 '21 at 04:29
2

I just had this problem setting up my new laptop. The issue for me was that my toolchain (CodeSourcery) is 32bit and I had not installed the 32bit libs.

sudo apt-get install ia32-libs
demongolem
  • 9,474
  • 36
  • 90
  • 105
jason
  • 31
  • 2