Hi, I am trying to set up a C project to be cross-platform with CMake and vcpkg. It works fine for me on windows, but on linux ubuntu sandbox it gives me this error when I run the following commands:
error: while detecting compiler information:
The log file content at "/root/vcpkg/buildtrees/detect_compiler/stdout-x64-linux.log" is:
-- Configuring x64-linux-rel
CMake Error at scripts/cmake/vcpkg_execute_required_process.cmake:112 (message):
Command failed: /root/vcpkg/downloads/tools/cmake-3.27.1-linux/cmake-3.27.1-linux-x86_64/bin/cmake /root/vcpkg/scripts/detect_compiler -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/root/vcpkg/packages/detect_compiler_x64-linux -DCMAKE_MAKE_PROGRAM=/root/vcpkg/downloads/tools/ninja/1.10.2-linux/ninja -DCMAKE_SYSTEM_NAME=Linux -DBUILD_SHARED_LIBS=OFF -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=/root/vcpkg/scripts/toolchains/linux.cmake -DVCPKG_TARGET_TRIPLET=x64-linux -DVCPKG_SET_CHARSET_FLAG=ON -DVCPKG_PLATFORM_TOOLSET=external -DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON -DCMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY=ON -DCMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY=ON -DCMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP=TRUE -DCMAKE_VERBOSE_MAKEFILE=ON -DVCPKG_APPLOCAL_DEPS=OFF -DCMAKE_TOOLCHAIN_FILE=/root/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION=ON -DVCPKG_CXX_FLAGS= -DVCPKG_CXX_FLAGS_RELEASE= -DVCPKG_CXX_FLAGS_DEBUG= -DVCPKG_C_FLAGS= -DVCPKG_C_FLAGS_RELEASE= -DVCPKG_C_FLAGS_DEBUG= -DVCPKG_CRT_LINKAGE=dynamic -DVCPKG_LINKER_FLAGS= -DVCPKG_LINKER_FLAGS_RELEASE= -DVCPKG_LINKER_FLAGS_DEBUG= -DVCPKG_TARGET_ARCHITECTURE=x64 -DCMAKE_INSTALL_LIBDIR:STRING=lib -DCMAKE_INSTALL_BINDIR:STRING=bin -D_VCPKG_ROOT_DIR=/root/vcpkg -DZ_VCPKG_ROOT_DIR=/root/vcpkg -D_VCPKG_INSTALLED_DIR=/root/CLox/build/vcpkg_installed -DVCPKG_MANIFEST_INSTALL=OFF
Working Directory: /root/vcpkg/buildtrees/detect_compiler/x64-linux-rel
Error code: 1
See logs for more information:
/root/vcpkg/buildtrees/detect_compiler/config-x64-linux-rel-CMakeCache.txt.log
/root/vcpkg/buildtrees/detect_compiler/config-x64-linux-rel-out.log
/root/vcpkg/buildtrees/detect_compiler/config-x64-linux-rel-err.log
Call Stack (most recent call first):
scripts/cmake/vcpkg_configure_cmake.cmake:344 (vcpkg_execute_required_process)
scripts/detect_compiler/portfile.cmake:18 (vcpkg_configure_cmake)
scripts/ports.cmake:147 (include)
error: vcpkg was unable to detect the active compiler's information. See above for the CMake failure output.
-- Running vcpkg install - failed
CMake Error at /root/vcpkg/scripts/buildsystems/vcpkg.cmake:895 (message):
vcpkg install failed. See logs for more information:
/root/CLox/build/vcpkg-manifest-install.log
Call Stack (most recent call first):
/usr/share/cmake-3.22/Modules/CMakeDetermineSystem.cmake:124 (include)
CMakeLists.txt:5 (project)
CMake Error: CMake was unable to find a build program corresponding to "Unix Makefiles". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
It seems that cmake/vcpkg isnt able to find the C compiler, though if I remove the vcpkg dependency it seems to work fine. Also the same command works perfectly on windows, is there a reason why it is having this issue on Linux?
-- The C compiler identification is GNU 11.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- The CXX compiler identification is unknown
-- Configuring incomplete, errors occurred!
CMake Error at CMakeLists.txt:12 (enable_language):
No CMAKE_CXX_COMPILER could be found.
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.
What C++ compiler are you expecting it to pick up? The output shows that it picks up /usr/bin/cc as the C compiler. Do you have a C++ compiler installed on your Linux machine?