Issue
I'm new to C++, really trying to get familiar with CMake, but there's always something wrong.
I'm using CLion with Cygwin and G++11 package installed
My CMakeLists.txt file:
cmake_minimum_required(VERSION 3.20)
project(testing)
set(CMAKE_CXX_STANDARD 20)
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif ()
set(CMAKE_CXX_FLAGS "-Wall -Wextra")
set(CMAKE_CXX_FLAGS_DEBUG "-g")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
add_executable(testing main.cpp)
Clion says me that execution
header is not found, but I could locate it in lib/
folder:
Could somebody tell me what I'm doing wrong?
Solution
Here are a few things I have tried when debugging similar problems:
- If in doubt, delete and re-create your build directories. CMake caches certain variables and can sometimes get into a weird state. A fresh directory will remove any uncertainty.
- CMake should print out what compiler it is using - Check that and make sure it's correct. For example, it could be finding an older version that does not have that header.
- In this case, the fix may be to put your desired compiler at the front of your
PATH
, or to force CMake to find the correct one viaCMAKE_CXX_COMPILER
.
- In this case, the fix may be to put your desired compiler at the front of your
- Build in verbose mode - you should be able to see what include paths are being used (
-I
,-isystem
). Make sure that directory is in there.- Alternatively, you can dump a
compile_commands.json
file that should contain the same information by settingCMAKE_EXPORT_COMPILE_COMMANDS=true
- Try using one of these build commands to build a single object in your Cygwin shell. If it works, it may indicate a problem with how your CLion is configured.
- Alternatively, you can dump a
Answered By - 0x5453 Answer Checked By - Gilberto Lyons (WPSolving Admin)