Description
When I configure the build directory with
cmake .. -DCMAKE_BUILD_TYPE:STRING=Release -G Ninja -DCMAKE_C_COMPILER:STRING=clang-12 -DCMAKE_CXX_COMPILER:STRING=clang++-12 -DMJPC_BUILD_GRPC_SERVICE:BOOL=ON
under Ubuntu 22.04 with Clang-12 installed, I encountered the following error:
==============================================================================================
-- The C compiler identification is Clang 12.0.1
-- The CXX compiler identification is Clang 12.0.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/clang-12 - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Check for working CXX compiler: /usr/bin/clang++-12
-- Check for working CXX compiler: /usr/bin/clang++-12 - broken
CMake Error at /usr/share/cmake-3.22/Modules/CMakeTestCXXCompiler.cmake:62 (message):
The C++ compiler
"/usr/bin/clang++-12"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /home/oscar/mujoco_mpc/build/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/bin/ninja cmTC_73a1c && [1/2] Building CXX object CMakeFiles/cmTC_73a1c.dir/testCXXCompiler.cxx.o
[2/2] Linking CXX executable cmTC_73a1c
FAILED: cmTC_73a1c
: && /usr/bin/clang++-12 CMakeFiles/cmTC_73a1c.dir/testCXXCompiler.cxx.o -o cmTC_73a1c && :
/usr/bin/ld: cannot find -lstdc++: No such file or directory
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:25 (project)
-- Configuring incomplete, errors occurred!
==============================================================================================
After googling the problem, I need to install this
sudo apt-get install libstdc++-12-dev
Then clean up the build directory and configure again with success. After that, continue the build process.