I am trying to use Qt Creator to work on a non-Qt C++ program, built using CMake with Clang as the compiler. Platform is Windows 10 64. All versions are most recent at time of this post. After manually downloading Jom and adding it to the path, I get this error trying to build a Hello World program:
The C compiler identification is Clang 6.0.0
The CXX compiler identification is Clang 6.0.0
Check for working C compiler: C:/Program Files/LLVM/bin/clang-cl.exe
Check for working C compiler: C:/Program Files/LLVM/bin/clang-cl.exe -- broken
CMake Error at C:/Program Files/CMake/share/cmake-3.12/Modules/CMakeTestCCompiler.cmake:52 (message):
The C compiler
"C:/Program Files/LLVM/bin/clang-cl.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/Users/Alex/AppData/Local/Temp/QtCreator-zKOojN/qtc-cmake-TXXABrTJ/CMakeFiles/CMakeTmp
Run Build Command:"jom" "/nologo" "cmTC_75f57\fast"
jom: parallel job execution disabled for Makefile
C:\apps\Jom\jom.exe -f CMakeFiles\cmTC_75f57.dir\build.make /nologo -L CMakeFiles\cmTC_75f57.dir\build
Building C object CMakeFiles/cmTC_75f57.dir/testCCompiler.c.obj
C:\PROGRA~1\LLVM\bin\clang-cl.exe #C:\Users\Alex\AppData\Local\Temp\testCCompiler.c.obj.12652.16.jom
Linking C executable cmTC_75f57.exe
"C:\Program Files\CMake\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\cmTC_75f57.dir --manifests -- llvm-ld /nologo #CMakeFiles\cmTC_75f57.dir\objects1.rsp #C:\Users\Alex\AppData\Local\Temp\cmTC_75f57.exe.12652.297.jom
RC Pass 1: command "rc /foCMakeFiles\cmTC_75f57.dir/manifest.res CMakeFiles\cmTC_75f57.dir/manifest.rc" failed (exit code 0) with the following output:
The system cannot find the file specifiedjom: C:\Users\Alex\AppData\Local\Temp\QtCreator-zKOojN\qtc-cmake-TXXABrTJ\CMakeFiles\CMakeTmp\CMakeFiles\cmTC_75f57.dir\build.make [cmTC_75f57.exe] Error 2
jom: C:\Users\Alex\AppData\Local\Temp\QtCreator-zKOojN\qtc-cmake-TXXABrTJ\CMakeFiles\CMakeTmp\Makefile [cmTC_75f57\fast] Error 2
Here is my CMakeLists.txt file:
cmake_minimum_required(VERSION 2.8)
SET (CMAKE_C_COMPILER "clang-cl")
SET (CMAKE_C_FLAGS "-Wall -std=c99")
SET (CMAKE_C_FLAGS_DEBUG "-g")
SET (CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG")
SET (CMAKE_C_FLAGS_RELEASE "-O4 -DNDEBUG")
SET (CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g")
SET (CMAKE_CXX_COMPILER "clang-cl")
SET (CMAKE_CXX_FLAGS "-Wall")
SET (CMAKE_CXX_FLAGS_DEBUG "-g")
SET (CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG")
SET (CMAKE_CXX_FLAGS_RELEASE "-O4 -DNDEBUG")
SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
SET (CMAKE_AR "llvm-ar")
SET (CMAKE_LINKER "llvm-ld")
SET (CMAKE_NM "llvm-nm")
SET (CMAKE_OBJDUMP "llvm-objdump")
SET (CMAKE_RANLIB "llvm-ranlib")
project(TestProg)
add_executable(${PROJECT_NAME} "main.cpp")
Related
I've got MSVS 2022 and clang llvm installed on win10, I'm using vscode and cmake(version 3.23.2). On powershell command line I have a directory containing several cpp files and a CMakeLists.txt, then:
mkdir build
cd build
cmake -D CMAKE_TOOLCHAIN_FILE="..\cmaketoolchain.win10clang" ..
The content of cmaketoolchain.win10clang is as below:
set(CMAKE_C_COMPILER "clang")
set(CMAKE_CXX_COMPILER "clang++")
SET (CMAKE_C_COMPILER "d:\\Program Files\\LLVM\\bin\\clang.exe")
SET (CMAKE_C_FLAGS "-Wall -std=c99")
SET (CMAKE_C_FLAGS_DEBUG "-g")
SET (CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG")
SET (CMAKE_C_FLAGS_RELEASE "-O4 -DNDEBUG")
SET (CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g")
SET (CMAKE_CXX_COMPILER "d:\\Program Files\\LLVM\\bin\\clang++.exe")
SET (CMAKE_CXX_FLAGS "-Wall")
SET (CMAKE_CXX_FLAGS_DEBUG "-g")
SET (CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG")
SET (CMAKE_CXX_FLAGS_RELEASE "-O4 -DNDEBUG")
SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
Well, on running cmake it still prints:
cmake -D CMAKE_TOOLCHAIN_FILE="..\cmaketoolchain.win10clang" ..
-- Building for: Visual Studio 17 2022
-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19043.
-- The C compiler identification is MSVC 19.31.31104.0
-- The CXX compiler identification is MSVC 19.31.31104.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: d:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.31.31103/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
...
And generate a bunch of vcproj files.
Did I miss anything about cmake or environmental setting? How to solve it?
I'm on win10 and I have installed: MSVS2022 with msc++ compiler, codeblocks with Mingwin-g++ compiler and then llvm clang.
I then installed latest cmake and have a very simple CMakeLists.txt in a directory named basic with some cc files:
cmake_minimum_required(VERSION 2.8)
project(my)
add_executable(my main.cc power.cc)
I do these commands in powershell:
mkdir build
cd build
cmake ../basic.
-- Building for: Visual Studio 17 2022
CMake Deprecation Warning at CMakeLists.txt:17 (cmake_minimum_required):
Compatibility with CMake < 2.8.12 will be removed from a future version of
CMake.
Update the VERSION argument <min> value or use a ...<max> suffix to tell
CMake that the project does not need compatibility with older versions.
-- The C compiler identification is MSVC 19.31.31104.0
-- The CXX compiler identification is MSVC 19.31.31104.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: d:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.31.31103/bin/H
But I wish I could use g++ or clang++, so I tried several methods at the same time.
(1) I changed CMakeLists.txt to add some lines:
set(CMAKE_C_COMPILER "clang")
set(CMAKE_CXX_COMPILER "clang++")
SET (CMAKE_C_COMPILER "d:\\Program Files\\LLVM\\bin\\clang.exe")
SET (CMAKE_C_FLAGS "-Wall -std=c99")
SET (CMAKE_C_FLAGS_DEBUG "-g")
SET (CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG")
SET (CMAKE_C_FLAGS_RELEASE "-O4 -DNDEBUG")
SET (CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g")
SET (CMAKE_CXX_COMPILER "d:\\Program Files\\LLVM\\bin\\clang++.exe")
SET (CMAKE_CXX_FLAGS "-Wall")
SET (CMAKE_CXX_FLAGS_DEBUG "-g")
SET (CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG")
SET (CMAKE_CXX_FLAGS_RELEASE "-O4 -DNDEBUG")
SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
cmake_minimum_required(VERSION 2.8)
project(my)
add_executable(my main.cc power.cc)
I cleaned the directory under build and run cmake again. Doesn't work, still choose msvc compiler.
Then I set environmental variable in Powershell like this:
$env:CC="d:\Program Files\LLVM\bin\clang.exe"
$env:CXX="d:\Program Files\LLVM\bin\clang++.exe"
I tried again. Doesn' work. Then I used the command line option:
cmake ..\basic\ -DCMAKE_CXX_COMPILER="d:\Program Files\LLVM\bin\clang++.exe"
Doesn't work. All methods tried together, still chooses msvc.
How to solve this problem?
I'm running CentOS 7.8 via dual-boot on a 64-bit 2013 Mac with a GT 650M GPU. I'm using CMake 3.17, CUDA 10.0, and GCC 4.8.5. All CUDA samples have been tested and work fine, and I'm able to compile other standard C++ code perfectly.
I've reduced my full project to a simple test case as follows, where the CMakeLists file is:
CMAKE_MINIMUM_REQUIRED(VERSION 3.8)
PROJECT(test LANGUAGES CUDA CXX C)
SET(CMAKE_VERBOSE_MAKEFILE ON)
MESSAGE(STATUS "Setting to Release mode")
SET(CMAKE_BUILD_TYPE "Release")
# Set CUDA flags
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -arch=sm_30 -rdc=true")
# Set flags
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall -ffast-math")
MESSAGE(STATUS "Setting g++ flags for Release configuration")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3") ## Optimize
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s ") ## Strip binary
ADD_SUBDIRECTORY( src )
In the /src folder I have another CMake file to gather the source files:
INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} )
INCLUDE_DIRECTORIES( ${CMAKE_BINARY_DIR} )
SET(test_SRCS
rsmain.cu
SGP4.cu
SGP4.cuh
)
function(my_add_executable TargetName)
set(Files ${ARGV})
list(REMOVE_AT Files 0)
add_executable(${TargetName} ${Files})
set_target_properties(${TargetName} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY
"${CMAKE_SOURCE_DIR}/build")
endfunction()
my_add_executable(test ${test_SRCS})
INSTALL( TARGETS test DESTINATION bin)
As shown, there are three main source files - both SGP4.cu and SGP4.cuh are empty, while rsmain.cu is simply:
/// Main function
int main(int argc, char *argv[])
{
return 0;
}
When trying to build, I get the following output:
[me#localhost build]$ cmake3 ..
-- The CUDA compiler identification is NVIDIA 10.0.130
-- The CXX compiler identification is GNU 4.8.5
-- The C compiler identification is GNU 4.8.5
-- Check for working CUDA compiler: /usr/local/cuda-10.0/bin/nvcc
-- Check for working CUDA compiler: /usr/local/cuda-10.0/bin/nvcc - works
-- Detecting CUDA compiler ABI info
-- Detecting CUDA compiler ABI info - done
-- Detecting CUDA compile features
-- Detecting CUDA compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ - works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc - works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- No build configuration specified, defaulting to Release
-- Setting general compiler flags for detected compiler: gnu-g++
-- Setting g++ flags for Release configuration
-- Configuring done
-- Generating done
-- Build files have been written to: /home/me/Documents/test/build
[me#localhost build]$ make
/usr/bin/cmake3 -S/home/me/Documents/test -B/home/me/Documents/test/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake3 -E cmake_progress_start /home/me/Documents/test/build/CMakeFiles /home/me/Documents/test/build/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory `/home/me/Documents/test/build'
make -f src/CMakeFiles/test.dir/build.make src/CMakeFiles/test.dir/depend
make[2]: Entering directory `/home/me/Documents/test/build'
cd /home/me/Documents/test/build && /usr/bin/cmake3 -E cmake_depends "Unix Makefiles" /home/me/Documents/test /home/me/Documents/test/src /home/me/Documents/test/build /home/me/Documents/test/build/src /home/me/Documents/test/build/src/CMakeFiles/test.dir/DependInfo.cmake --color=
Scanning dependencies of target test
make[2]: Leaving directory `/home/me/Documents/test/build'
make -f src/CMakeFiles/test.dir/build.make src/CMakeFiles/test.dir/build
make[2]: Entering directory `/home/me/Documents/test/build'
[ 33%] Building CUDA object src/CMakeFiles/test.dir/rsmain.cu.o
cd /home/me/Documents/test/build/src && /usr/local/cuda-10.0/bin/nvcc -I/home/me/Documents/test/src -I/home/me/Documents/test/build/src -I/home/me/Documents/test/build -arch=sm_30 -rdc=true -O3 -DNDEBUG -std=c++03 -x cu -c /home/me/Documents/test/src/rsmain.cu -o CMakeFiles/test.dir/rsmain.cu.o
[ 66%] Building CUDA object src/CMakeFiles/test.dir/SGP4.cu.o
cd /home/me/Documents/test/build/src && /usr/local/cuda-10.0/bin/nvcc -I/home/me/Documents/test/src -I/home/me/Documents/test/build/src -I/home/me/Documents/test/build -arch=sm_30 -rdc=true -O3 -DNDEBUG -std=c++03 -x cu -c /home/me/Documents/test/src/SGP4.cu -o CMakeFiles/test.dir/SGP4.cu.o
[100%] Linking CUDA executable ../test
cd /home/me/Documents/test/build/src && /usr/bin/cmake3 -E cmake_link_script CMakeFiles/test.dir/link.txt --verbose=1
/usr/bin/g++ -s CMakeFiles/test.dir/rsmain.cu.o CMakeFiles/test.dir/SGP4.cu.o -o ../test -lcudadevrt -lcudart_static -L"/usr/local/cuda-10.0/targets/x86_64-linux/lib/stubs" -L"/usr/local/cuda-10.0/targets/x86_64-linux/lib" -lcudadevrt -lcudart_static -lrt -lpthread -ldl
CMakeFiles/test.dir/rsmain.cu.o: In function `__sti____cudaRegisterAll()':
tmpxft_00004eed_00000000-5_rsmain.cudafe1.cpp:(.text.startup+0x25): undefined reference to `__cudaRegisterLinkedBinary_41_tmpxft_00004eed_00000000_6_rsmain_cpp1_ii_main'
CMakeFiles/test.dir/SGP4.cu.o: In function `__sti____cudaRegisterAll()':
tmpxft_00004f02_00000000-5_SGP4.cudafe1.cpp:(.text.startup+0x15): undefined reference to `__cudaRegisterLinkedBinary_39_tmpxft_00004f02_00000000_6_SGP4_cpp1_ii_71922fcb'
collect2: error: ld returned 1 exit status
make[2]: *** [test] Error 1
make[2]: Leaving directory `/home/me/Documents/test/build'
make[1]: *** [src/CMakeFiles/test.dir/all] Error 2
make[1]: Leaving directory `/home/me/Documents/test/build'
make: *** [all] Error 2
Could anyone please explain what this 'cudaRegisterLinkedBinary' stuff is all about? I've tried a bunch of things in trying to solve it but nothing has worked so far. Is there an issue with any of the package versions? A problem in CMakeLists? Compatibility issues with CUDA and my hardware?
It's worth noting that the full code compiled and ran perfectly when I tested it on a HPC server (also running CentOS 7 and Cuda 10.0) - but on my personal PC it fails at the linking step. I've even confirmed that the .bashrc files are the same across both installations, but it hasn't fixed anything. I'm also currently able to compile NVIDIA's OptiX software (which also uses CUDA) without any problems.
Any advice would be appreciated. Please let me know if I missed any required details.
EDIT: Answer added below. Resolved.
Finally sorted this out. This was my main CMakeLists file:
CMAKE_MINIMUM_REQUIRED(VERSION 3.8)
PROJECT(test LANGUAGES C CXX CUDA)
SET(CMAKE_BUILD_TYPE "Release")
# Set CUDA flags
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -arch=sm_30 -rdc=true")
# Set flags
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall -ffast-math -O3")
MESSAGE(STATUS "Setting g++ flags for Release configuration")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s") ## Strip binary
ADD_SUBDIRECTORY( src )
And in the /src CMakeLists file, I had to make the change:
INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} )
INCLUDE_DIRECTORIES( ${CMAKE_BINARY_DIR} )
SET(test_SRCS
rsmain.cu
SGP4.cu
SGP4.cuh
)
function(my_add_executable TargetName)
set(Files ${ARGV})
list(REMOVE_AT Files 0)
add_executable(${TargetName} ${Files})
set_target_properties(${TargetName} PROPERTIES CUDA_RESOLVE_DEVICE_SYMBOLS ON
RUNTIME_OUTPUT_DIRECTORY
"${CMAKE_SOURCE_DIR}/build")
endfunction()
my_add_executable(test ${test_SRCS})
INSTALL( TARGETS test DESTINATION bin)
Setting CUDA_RESOLVE_DEVICE_SYMBOLS to ON is the change. In my main project, I also had to repeat this for every target involving any CUDA files. Everything compiles and runs perfectly now.
I am working an a hello-world level program using wxWidgets in Ubuntu.
The code compiles with
g++ HelloWorld.cpp `wx-config --libs` `wx-config --cxxflags` -o HelloWorldApp -I../inc
maot#HP-Pavilion-dv7:~/Perforce/maot_HP_Pavilion_dv7_full_02/WxWidgets/Learning_01/src$ which wx-config
/home/maot/Perforce/wxWidgets-3.1.0/gtk-build/wx-config
maot#HP-Pavilion-dv7:~/Perforce/maot_HP_Pavilion_dv7_full_02/WxWidgets/Learning_01/src$
...which makes sense because I put the path to wx-config in the PATH environment variable. I compiled wxWidgets myself.
Now I want to use cmake. My CMakeLists.txt file attempt:
cmake_minimum_required(VERSION 2.8.9)
project(WxWidgets_Learning_01)
set(CMAKE_CXX_COMPILER /usr/bin/g++)
message("CMAKE_CXX_FLAGS_DEBUG = ${CMAKE_CXX_FLAGS_DEBUG}")
message("CMAKE_CXX_FLAGS_RELEASE = ${CMAKE_CXX_FLAGS_RELEASE}")
set(CMAKE_CXX_FLAGS_DEBUG " -g3 ")
set(CMAKE_CXX_FLAGS_RELEASE "")
message("CMAKE_CXX_FLAGS_DEBUG = ${CMAKE_CXX_FLAGS_DEBUG}")
message("CMAKE_CXX_FLAGS_RELEASE = ${CMAKE_CXX_FLAGS_RELEASE}")
include_directories(../inc)
include_directories(../api/IBJts/source/cppclient/client)
include_directories(../api/IBJts/source/cppclient)
# wxWidgets header files start
include_directories(/home/maot/Perforce/wxWidgets-3.1.0/include)
include_directories(/home/maot/Perforce/wxWidgets-3.1.0/gtk-build/lib/wx/include/gtk2-unicode-3.1)
# wxWidgets header files end
# wxWidgets defines start
add_definitions(-D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXGTK__)
# wxWidgets defines finish
# Directories with wxWidget libs start
link_directories(/home/maot/Perforce/wxWidgets-3.1.0/gtk-build/lib)
# Directories with wxWidget libs finish
SET(wxWidgets_ROOT_DIR /home/maot/Perforce/wxWidgets-3.1.0/gtk-build/lib)
SET(wxWidgets_CONFIGURATION mswud)
# https://cmake.org/cmake/help/v3.0/module/FindwxWidgets.html
# Note that for MinGW users the order of libs is important!
find_package(wxWidgets COMPONENTS net gl core base REQUIRED)
include(${wxWidgets_USE_FILE})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra -Wall -pthread -lm ")
file(GLOB sources "../src/*.cpp" )
file(GLOB headers "../inc/*.h" )
set(daytrading_sources ${sources} ${headers})
add_executable(WxWidgets_Learning_01 ${sources})
target_link_libraries(${PROJECT_NAME} ${wxWidgets_LIBRARIES})
Output:
maot#HP-Pavilion-dv7:~/Perforce/maot_HP_Pavilion_dv7_full_02/WxWidgets/Learning_01/src$ \rm -rf CMakeFiles/ ; cmake .
-- The C compiler identification is GNU 7.2.0
-- The CXX compiler identification is GNU 7.2.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
CMAKE_CXX_FLAGS_DEBUG = -g
CMAKE_CXX_FLAGS_RELEASE = -O3 -DNDEBUG
CMAKE_CXX_FLAGS_DEBUG = -g3
CMAKE_CXX_FLAGS_RELEASE =
CMake Error at /usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:108 (message):
Could NOT find wxWidgets (missing: wxWidgets_FOUND)
Call Stack (most recent call first):
/usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:315 (_FPHSA_FAILURE_MESSAGE)
/usr/share/cmake-2.8/Modules/FindwxWidgets.cmake:832 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
CMakeLists.txt:40 (find_package)
-- Configuring incomplete, errors occurred!
See also "/home/maot/Perforce/maot_HP_Pavilion_dv7_full_02/WxWidgets/Learning_01/src/CMakeFiles/CMakeOutput.log".
maot#HP-Pavilion-dv7:~/Perforce/maot_HP_Pavilion_dv7_full_02/WxWidgets/Learning_01/src$
I think find_package can not find wxWidgets and I do not understand why. I am uncertain about this mswud thing because I can not find explanations about it; ms sounds like Bill G. I have tried a few values for wxWidgets_ROOT_DIR but no luck. Any help is welcome: What value should wxWidgets_ROOT_DIR have, and is mswud any good?
=== Edit below ===
I followed https://wiki.wxwidgets.org/Compiling_and_getting_started, using the --prefix=$(pwd) option. make install is not needed, it sais.
How to put the results of wx-config in CMakeLists.txt?
maot#HP-Pavilion-dv7:~$ wx-config --cxxflags
-I/home/maot/Perforce/wxWidgets-3.1.0/gtk-build/lib/wx/include/gtk2-unicode-3.1 -I/home/maot/Perforce/wxWidgets-3.1.0/include -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXGTK__ -pthread
maot#HP-Pavilion-dv7:~$
maot#HP-Pavilion-dv7:~$ wx-config --libs
-L/home/maot/Perforce/wxWidgets-3.1.0/gtk-build/lib -pthread -Wl,-rpath,/home/maot/Perforce/wxWidgets-3.1.0/gtk-build/lib -lwx_gtk2u_xrc-3.1 -lwx_gtk2u_html-3.1 -lwx_gtk2u_qa-3.1 -lwx_gtk2u_adv-3.1 -lwx_gtk2u_core-3.1 -lwx_baseu_xml-3.1 -lwx_baseu_net-3.1 -lwx_baseu-3.1
maot#HP-Pavilion-dv7:~$
I got my code compiling and running using the CMakeLists.txt file below; I realise it is not the way things are intended.
cmake_minimum_required(VERSION 2.8.9)
project(WxWidgets_Learning_01)
set(CMAKE_CXX_COMPILER /usr/bin/g++)
message("CMAKE_CXX_FLAGS_DEBUG = ${CMAKE_CXX_FLAGS_DEBUG}")
message("CMAKE_CXX_FLAGS_RELEASE = ${CMAKE_CXX_FLAGS_RELEASE}")
set(CMAKE_CXX_FLAGS_DEBUG " -g3 ")
set(CMAKE_CXX_FLAGS_RELEASE "")
message("CMAKE_CXX_FLAGS_DEBUG = ${CMAKE_CXX_FLAGS_DEBUG}")
message("CMAKE_CXX_FLAGS_RELEASE = ${CMAKE_CXX_FLAGS_RELEASE}")
include_directories(../inc)
include_directories(../api/IBJts/source/cppclient/client)
include_directories(../api/IBJts/source/cppclient)
# wxWidgets header files start
include_directories(../../../../wxWidgets-3.1.0/include)
include_directories(../../../../wxWidgets-3.1.0/gtk-build/lib/wx/include/gtk2-unicode-3.1)
# wxWidgets header files end
# wxWidgets defines start
add_definitions(-D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXGTK__)
# wxWidgets defines finish
# Directories with wxWidget libs start
link_directories(../../../../wxWidgets-3.1.0/gtk-build/lib)
# Directories with wxWidget libs finish
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra -Wall -pthread -lm ")
file(GLOB sources "../src/*.cpp" )
file(GLOB headers "../inc/*.h" )
set(daytrading_sources ${sources} ${headers})
add_executable(WxWidgets_Learning_01 ${sources})
target_link_libraries(WxWidgets_Learning_01
libwx_baseu-3.1.so
libwx_gtk2u_adv-3.1.so
libwx_gtk2u_gl-3.1.so
libwx_gtk2u_qa-3.1.so
libwx_gtk2u_stc-3.1.so
libwx_baseu_net-3.1.so
libwx_gtk2u_aui-3.1.so
libwx_gtk2u_html-3.1.so
libwx_gtk2u_ribbon-3.1.so
libwx_gtk2u_xrc-3.1.so
libwx_baseu_xml-3.1.so
libwx_gtk2u_core-3.1.so
libwx_gtk2u_propgrid-3.1.so
libwx_gtk2u_richtext-3.1.so
)
# I have just added all .so files that I found after the build.
If you need to compile just a simple example for the prototype then thats it.
However, if you need to compile some big project - you can try to set up Anjuta/CodeBlocks/CodeLite to help. It will benefit you in the long run (especially CodeBlocks).
In terms of your questions: mswud is not good, since it (as name suggested) for Windows.
Also, for the include/lib directory you should use wx-config appropriate command, just as you used for command-line compiling.
You can also try to take a look at CMake effort by TobiasT in trac.wxwidgets.org.
It's the first time I encounter this error.
I am trying to clone openvr and get the hello opengl sample running, following their instructions:
cd samples
mkdir build
cd build
cmake .. -G "Visual Studio 14 2015 Win64" -DCMAKE_PREFIX_PATH=C:/Qt/5.6/msvc2013_64/lib/cmake
I get:
$ cmake .. -G "Visual Studio 14 2015 Win64" -DCMAKE_PREFIX_PATH=C:/Qt/5.6/msvc20 13_64/lib/cmake
-- The C compiler identification is MSVC 19.0.24215.1
-- The CXX compiler identification is MSVC 19.0.24215.1
-- Check for working C compiler using: Visual Studio 14 2015 Win64
-- Check for working C compiler using: Visual Studio 14 2015 Win64 -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler using: Visual Studio 14 2015 Win64
-- Check for working CXX compiler using: Visual Studio 14 2015 Win64 -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Compilation set for 64bits architectures.
CMake Warning at CMakeLists.txt:40 (message):
SDL x64 runtime binaries not provided on Windows.
CMake Error at CMakeLists.txt:98 (message):
Unsupported compiler.
-- Configuring incomplete, errors occurred!
See also "C:/Users/GBarbieri/Documents/Visual Studio 2015/Projects/openvr/sample s/build/CMakeFiles/CMakeOutput.log".
If I go to check line 98:
if( (${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")
OR (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang"))
# Better to use the prebuilt GNU preprocessor define __GNUC__,
# kept for legacy reason with the sample code.
add_definitions(-DGNUC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -include ${SHARED_SRC_DIR}/compat.h")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -Wextra -pedantic -g")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2")
# Handles x86 compilation support on x64 arch.
if(${PLATFORM} MATCHES 32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32")
endif()
elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "MSVC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Za")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /w2 /DEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MP /INCREMENTAL:NO")
else()
message(FATAL_ERROR "Unsupported compiler. ") // line 98
endif()
It seems it couldn't match "MSVC".. let me do a try, let me add before this snippet of code:
message("${CMAKE_CXX_COMPILER_ID}")
if(${CMAKE_CXX_COMPILER_ID} MATCHES "MSVC")
message("match")
else()
message("!match")
endif()
And then it returns:
MSVC
!match
CMake Error at CMakeLists.txt:104 (message):
Unsupported compiler.
What?
Can you spot what is wrong, guys?
Ok, as I've tried in the comment, the right answer is to use:
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
instead of
if(${CMAKE_CXX_COMPILER_ID} MATCHES "MSVC")