How to set CMAKE_C_COMPILER and CMAKE_CXX_COMPILER?

Hi all,

I am trying to run and example of new crate physx-rs. While building it I am getting the following error.

 dinesh@desktop (master) /home/dinesh/phd/code/rust/physx-rs/physx $  
|  Dell Laptop=> cargo run --example ball_physx
   Compiling physx-sys v0.1.0+4.1
   Compiling alga v0.9.1
   Compiling syn v0.15.44
   Compiling parking_lot v0.9.0
error: failed to run custom build command for `physx-sys v0.1.0+4.1`

Caused by:
  process didn't exit successfully: `/home/dinesh/phd/code/rust/physx-rs/target/debug/build/physx-sys-de23c56b888ca170/build-script-build` (exit code: 101)
--- stdout
running: "cmake" "/home/dinesh/.cargo/registry/src/github.com-1ecc6299db9ec823/physx-sys-0.1.0+4.1/PhysX/physx/source/compiler/cmake" "-DCMAKE_LIBRARY_ARCHITECTURE=x86_64-unknown-linux-gnu" "-DPX_OUTPUT_LIB_DIR=/home/dinesh/phd/code/rust/physx-rs/target/debug/build/physx-sys-c78003c5b37d0e5a/out" "-DPX_OUTPUT_BIN_DIR=/home/dinesh/phd/code/rust/physx-rs/target/debug/build/physx-sys-c78003c5b37d0e5a/out" "-DPX_OUTPUT_ARCH=x86" "-DPX_BUILDSNIPPETS=False" "-DPX_BUILDSAMPLES=False" "-DPX_GENERATE_STATIC_LIBRARIES=True" "-DPX_GENERATE_GPU_PROJECTS=False" "-DTARGET_BUILD_PLATFORM=linux" "-DCMAKE_C_COMPILER=clang" "-DCMAKE_CXX_COMPILER=clang++" "-DCMAKE_BUILD_TYPE=debug" "-DCMAKE_INSTALL_PREFIX=/home/dinesh/phd/code/rust/physx-rs/target/debug/build/physx-sys-c78003c5b37d0e5a/out" "-DCMAKE_C_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_CXX_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64"
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
-- Configuring incomplete, errors occurred!
See also "/home/dinesh/phd/code/rust/physx-rs/target/debug/build/physx-sys-c78003c5b37d0e5a/out/build/CMakeFiles/CMakeOutput.log".
See also "/home/dinesh/phd/code/rust/physx-rs/target/debug/build/physx-sys-c78003c5b37d0e5a/out/build/CMakeFiles/CMakeError.log".

--- stderr
CMake Error at CMakeLists.txt:30 (project):
  The CMAKE_C_COMPILER:

    clang

  is not a full path and was not found in the PATH.

  Tell CMake where to find the compiler by setting either the environment
  variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
  the compiler, or to the compiler name if it is in the PATH.


CMake Error at CMakeLists.txt:30 (project):
  The CMAKE_CXX_COMPILER:

    clang++

  is not a full path and was not found in the PATH.

  Tell CMake where to find the compiler by setting either the environment
  variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
  to the compiler, or to the compiler name if it is in the PATH.


thread 'main' panicked at '
command did not execute successfully, got: exit code: 1

build script failed, must exit now', /home/dinesh/.cargo/registry/src/github.com-1ecc6299db9ec823/cmake-0.1.41/src/lib.rs:835:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

warning: build failed, waiting for other jobs to finish...
error: build failed
 

I am a programmer coming from python, and don't know much C or C++ language. Can some body help about setting these variables?

I am using Ubuntu os.

Thank you.

Do you have a C++ compiler installed? Something like apt-get install build-essential should help.

1 Like

Turns out I don't have clang compiler. Works by

sudo apt install clang