I am new in c++
The cmakelist.txt file dont give me a Makefile
-- Building for: Visual Studio 16 2019
-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.22000.
-- The C compiler identification is MSVC 19.29.30140.0
-- The CXX compiler identification is MSVC 19.29.30140.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/JohnSmith/Documents/Hello/build
I dont know how to change the compiler to G++
this is the cmake
cmake_minimum_required(VERSION 3.0)
set(CMAKE_C_COMPILER "gcc")
set(CMAKE_CXX_COMPILER "g++")
project(HelLo)
add_executable(Hello main.cpp hello.cpp)
I am on windows , Thanks for help
(I can compile with g++ and gcc just cmakefile dont work )
First, make sure you've installed gcc/g++ under Windows (either CygWin or MinGW). Remove the set commands from your CMakelists.txt. Then in a CygWin/MinGW shell use the following command to generate the Makefile:
CC=gcc CXX=c++ cmake ..
cmake -G "Unix Makefiles" ..
Related
When using this CMakeLists.txt
cmake_minimum_required(VERSION 3.17)
project(project_c)
set(CMAKE_CXX_STANDARD 11)
set(project_name project_c)
find_package(BISON)
find_package(FLEX)
BISON_TARGET(parser parser.y ${CMAKE_SOURCE_DIR}/parser.cpp)
FLEX_TARGET(lexer lexer.l ${CMAKE_SOURCE_DIR}/lexer.cpp)
ADD_FLEX_BISON_DEPENDENCY(lexer parser)
add_executable(${project_name} ${BISON_parser_OUTPUTS} ${FLEX_lexer_OUTPUTS})
target_include_directories(${project_name} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}")
target_link_libraries(${project_name} ${FLEX_LIBRARIES})
CMake complains about
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
FL_LIBRARY (ADVANCED)
linked by target "project_c" in directory D:/asant/workspace/CLionProjects/project_c
I've tried to copy the winflex folder inside the project folder but that won't help anyway. This proposed solution isn't working.
This is the complete CMake log
"C:\Program Files\JetBrains\CLion 2018.3.4\bin\cmake\win\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - MinGW Makefiles" D:\asant\workspace\CLionProjects\project_c
-- The C compiler identification is GNU 8.1.0
-- The CXX compiler identification is GNU 8.1.0
-- Check for working C compiler: C:/Qt/Tools/mingw810_64/bin/gcc.exe
-- Check for working C compiler: C:/Qt/Tools/mingw810_64/bin/gcc.exe - works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/Qt/Tools/mingw810_64/bin/g++.exe
-- Check for working CXX compiler: C:/Qt/Tools/mingw810_64/bin/g++.exe - works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found BISON: C:/Program Files (x86)/win_flex_bison-2.5.23/win_bison.exe (found version "3.7.1")
-- Found FLEX: C:/Program Files (x86)/win_flex_bison-2.5.23/win_flex.exe (found version "2.6.4")
-- Configuring done
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
FL_LIBRARY (ADVANCED)
linked by target "project_c" in directory D:/asant/workspace/CLionProjects/project_c
-- Generating done
CMake Generate step failed. Build files cannot be regenerated correctly.
[Failed to reload]
I've managed to build a WxWidgets based on CMake on Ubuntu 19.10, but failed on Windows 10, saying that it cannot find WxWidgets, though I've built it successfully (static, release and with unicode support).
WxWidgets path is C:\wxWidgets-3.1.3 and the build directory is C:\wxWidgets-3.1.3\msw-release.
The makefile is
cmake_minimum_required(VERSION 3.0)
project(ChessPgnReviser VERSION 0.1.0)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
ADD_DEFINITIONS(-Wall -Wno-sign-compare -O2)
set(SRCS
src/main.cpp
)
set (HEADERS
)
message( "--Root--" ${wxWidgets_ROOT_DIR} )
message( "--Lib dir--" ${wxWidgets_LIB_DIR} )
add_executable(ChessPgnReviser ${SRCS} ${HEADERS})
find_package(wxWidgets COMPONENTS net gl core base)
if(wxWidgets_FOUND)
include(${wxWidgets_USE_FILE})
target_link_libraries(ChessPgnReviser ${wxWidgets_LIBRARIES})
else()
message(FATAL_ERROR "Failed to find WxWidgets library")
endif()
I'm using Msys 64 bit in order to compile the project. At the bottom of its subfolder etc/profile, I've added
PATH=$PATH:/c/dev/cmake/bin
wxWidgets_ROOT_DIR=/c/wxWidgets-3.1.3
wxWidgets_LIBRARIES=$wxWidgets_ROOT_DIR/msw-release/lib
wxWidgets_LIB_DIR=$wxWidgets_ROOT_DIR/msw-release/lib
wxWidgets_INCLUDE_DIRS=$wxWidgets_ROOT_DIR/include
So I've tried
$ mkdir build && cd build
$ cmake .. -G "MinGW Makefiles"
-- The C compiler identification is GNU 10.1.0
-- The CXX compiler identification is GNU 10.1.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/msys64/mingw64/bin/gcc.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/msys64/mingw64/bin/g++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
--Root--
--Lib dir--
-- Could NOT find wxWidgets (missing: wxWidgets_LIBRARIES wxWidgets_INCLUDE_DIRS net gl core base)
CMake Error at CMakeLists.txt:27 (message):
Failed to find WxWidgets library
-- Configuring incomplete, errors occurred!
See also "C:/Users/laure/Documents/Programmation/ProjetsPersos/Cpp/ChessPgnReviserWxWidgets/build/CMakeFiles/CMakeOutput.log".
Also, thanks to #squareskittles, I also tried:
$ cmake .. -G "MinGW Makefiles" -DwxWidgets_ROOT_DIR="C:\wxWidgets-3.1.3" -DwxWidgets_LIB_DIR="C:\wxWidgets-3.1.3\msw-release\lib"
-- The C compiler identification is GNU 10.1.0
-- The CXX compiler identification is GNU 10.1.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/msys64/mingw64/bin/gcc.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/msys64/mingw64/bin/g++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
--Root--C:\wxWidgets-3.1.3
--Lib dir--C:\wxWidgets-3.1.3\msw-release\lib
-- Could NOT find wxWidgets (missing: wxWidgets_LIBRARIES wxWidgets_INCLUDE_DIRS net gl core base)
CMake Error at CMakeLists.txt:27 (message):
Failed to find WxWidgets library
-- Configuring incomplete, errors occurred!
See also "C:/Users/laure/Documents/Programmation/ProjetsPersos/Cpp/ChessPgnReviserWxWidgets/build/CMakeFiles/CMakeOutput.log".
You can find the content of the msw-release folder : there.
Also:
$ ls /c/wxWidgets-3.1.3/msw-release/lib/
libwx_baseu_net-3.1.a libwx_baseu-3.1.a libwx_mswu_aui-3.1.a libwx_mswu_gl-3.1.a libwx_mswu_media-3.1.a libwx_mswu_qa-3.1.a libwx_mswu_richtext-3.1.a libwx_mswu_webview-3.1.a libwxregexu-3.1.a wx
libwx_baseu_xml-3.1.a libwx_mswu_adv-3.1.a libwx_mswu_core-3.1.a libwx_mswu_html-3.1.a libwx_mswu_propgrid-3.1.a libwx_mswu_ribbon-3.1.a libwx_mswu_stc-3.1.a libwx_mswu_xrc-3.1.a libwxscintilla-3.1.a
So did I forget something ?
To properly detect wxWidgets you need wx-config.
A Windows version of wx-config exists and can be downloaded from: https://github.com/kowey/wx-config-win
To make wx-config know where your wxWidgets is, you need set the following environment variables:
WXWIN (in your case to C:/wxWidgets-3.1.3)
WXCFG (in your case to something like msw/gcc_mswu).
I'm trying to develop an engine for private use, I'm using CMake because I intend to make it multiplatform in the future, but an error started to appear that I never came across before, I tried to change project(IEngine) to project(IEngine CXX) as said in other questions from stack overflow, but the error persists, here's my CMakeLists
cmake_minimum_required(VERSION 3.16.2)
project(IEngine)
find_package(Vulkan REQUIRED)
file(GLOB_RECURSE SRC_RENDERER
"${IEngine_SOURCE_DIR}/src/Renderer/*.cpp"
"${IEngine_SOURCE_DIR}/src/Renderer/*.hpp"
"${IEngine_SOURCE_DIR}/src/Renderer/*.h")
source_group("Renderer" FILES ${SRC_RENDERER})
add_library(IEngine STATIC ${SRC_RENDERER})
if(WIN32)
target_compile_definitions(IEngine PRIVATE VK_USE_PLATFORM_WIN32_KHR)
endif()
target_include_directories(IEngine PRIVATE Vulkan::Vulkan)
target_link_libraries(IEngine Vulkan::Vulkan)
The output:
Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.18363.
The C compiler identification is MSVC 19.24.28315.0
The CXX compiler identification is MSVC 19.24.28315.0
Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.24.28314/bin/Hostx64/x64/cl.exe
Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.24.28314/bin/Hostx64/x64/cl.exe - works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Detecting C compile features
Detecting C compile features - done
Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.24.28314/bin/Hostx64/x64/cl.exe
Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.24.28314/bin/Hostx64/x64/cl.exe - works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Detecting CXX compile features
Detecting CXX compile features - done
Found Vulkan: A:/VulkanSDK/1.2.131.1/Lib/vulkan-1.lib
Configuring done
CMake Error: CMake can not determine linker language for target: IEngine
Generating done
I've had this error many times :( Add this to your CMakeLists.txt:
set_target_properties(IEngine PROPERTIES LINKER_LANGUAGE CXX)
I am trying to write a simple clang AST cursor traveler.
https://github.com/dyhe83/clang-AST-cursor-traveler
This following cmake code works fine on Linux.
PROJECT(traveler)
FIND_LIBRARY(LIBCLANG_PATH
clang HINTS /usr/local/lib/
)
ADD_EXECUTABLE(traveler
traveler.cpp
)
TARGET_LINK_LIBRARIES(traveler
${LIBCLANG_PATH}
)
I also want to run this example on windows.
My LLVM is build in "C:\Program Files (x86)\LLVM"
But after I changed the FIND_LIBRARY part of CMakeLists.txt.
FIND_LIBRARY(LIBCLANG_PATH
clang HINTS "C:\\Program Files (x86)\\LLVM\\lib"
)
Some error occurs:
D:\WorkSpace\C\clang-AST-cursor-traveler\build>cmake ..
-- Building for: Visual Studio 15 2017
-- The C compiler identification is MSVC 19.16.27025.1
-- The CXX compiler identification is MSVC 19.16.27025.1
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
LIBCLANG_PATH
linked by target "traveler" in directory D:/WorkSpace/C/clang-AST-cursor-traveler/src
-- Configuring incomplete, errors occurred!
See also "D:/WorkSpace/C/clang-AST-cursor-traveler/build/CMakeFiles/CMakeOutput.log".
And "C:\Program Files (x86)\LLVM\lib" have the libraries.
Does anyone know where is the correct clang library path on windows??
Try to set env virable in windows.
I mean the place where you add/edit PATH env virables
LIBCLANG_PATH=C:\Program Files (x86)\LLVM\lib
So, i set up my Cloin/SFML project like this : configure SFML for clion (windows)
and added the SFML_ROOT variable, and then it works exactly once, and every time i try too run it after the first, i get this error(gam is the project name, it is set correctly in the CMakeLists.txt file):
mingw32-make.exe: *** No rule to make target 'gam'. Stop.
How do i get it to work more than once?(It might be something as stupid as me clicking the wrong button to run this thing. I´m new to Clion and cmake)
CMakeLists.txt:
cmake_minimum_required(VERSION 3.12)
project(gam)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(SOURCE_FILES main.cpp)
add_executable(gam ${SOURCE_FILES})
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake_modules")
find_package(SFML REQUIRED system window graphics network audio)
if (SFML_FOUND)
include_directories(${SFML_INCLUDE_DIR})
target_link_libraries(gam ${SFML_LIBRARIES})
endif()
output of CMake when project is first initialized:
"C:\Program Files\JetBrains\CLion 2018.2.4\bin\cmake\win\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - MinGW Makefiles" D:\programierzeug\c++\test
-- The C compiler identification is GNU 8.1.0
-- The CXX compiler identification is GNU 8.1.0
-- Check for working C compiler: C:/Program Files (x86)/mingw-w64/i686-8.1.0-posix-dwarf-rt_v6-rev0/mingw32/bin/gcc.exe
-- Check for working C compiler: C:/Program Files (x86)/mingw-w64/i686-8.1.0-posix-dwarf-rt_v6-rev0/mingw32/bin/gcc.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/Program Files (x86)/mingw-w64/i686-8.1.0-posix-dwarf-rt_v6-rev0/mingw32/bin/g++.exe
-- Check for working CXX compiler: C:/Program Files (x86)/mingw-w64/i686-8.1.0-posix-dwarf-rt_v6-rev0/mingw32/bin/g++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: D:/programierzeug/c++/test/cmake-build-debug
[Finished]
output of CMake when reloading project:
"C:\Program Files\JetBrains\CLion 2018.2.4\bin\cmake\win\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - MinGW Makefiles" D:\programierzeug\c++\test
-- Configuring done
-- Generating done
-- Build files have been written to: D:/programierzeug/c++/test/cmake-build-debug
[Finished]