CMake could not find SDL2 - c++

I want to add this library to my project. However, it does not come with pre-compiled files. It asks me to build the library myself with cmake, which I am not familiar with. One of its dependencies is SDL2. So I download the sdl2 development libraries folder. In cmake, I click configure and choose the generator. After a couple of seconds processing, a window pops up showing the error: Error in configuration process project files may be invalid
And this is what the log screen shows:
The C compiler identification is MSVC 18.0.40629.0 The CXX
compiler identification is MSVC 18.0.40629.0 Check for working C
compiler using: Visual Studio 12 2013 Check for working C compiler
using: Visual Studio 12 2013 -- works Detecting C compiler ABI
info Detecting C compiler ABI info - done Check for working
CXX compiler using: Visual Studio 12 2013 Check for working CXX
compiler using: Visual Studio 12 2013 -- works Detecting CXX
compiler ABI info Detecting CXX compiler ABI info - done
Detecting CXX compile features Detecting CXX compile features -
done CMake Error at C:/Program Files
(x86)/CMake/share/cmake-3.4/Modules/FindPackageHandleStandardArgs.cmake:148
(message): Could NOT find SDL2 (missing: SDL2_INCLUDE_DIR
SDL2_LIBRARY) Call Stack (most recent call first):
C:/Program Files
(x86)/CMake/share/cmake-3.4/Modules/FindPackageHandleStandardArgs.cmake:388
(_FPHSA_FAILURE_MESSAGE) cmake/FindSDL2.cmake:18
(FIND_PACKAGE_HANDLE_STANDARD_ARGS) CMakeLists.txt:30 (FIND_PACKAGE)
Configuring incomplete, errors occurred! See also "E:/game
dev/libraries/libSDL2pp-master/build/CMakeFiles/CMakeOutput.log".
Could anyone tell me what to do? I am not sure that I am doing the right thing.

cmake doesn't come with a module for finding sdl2 by default. That's most likely the reason why you provided your own in cmake/FindSDL2.cmake. As you are on windows, it is most likely that you have to set an environment variable to point to the sdl2 installation directory (but this is really something that depends on the FindSDL2.cmake that you use).

Related

Qt Cmake error compilation "GuiSupportQt not found"

I'm new to Qt and i already have a problem so i start to create a simple UI for my VTK project, first of all, i tested a sample project UI designed by Qt in Qt 5.5.0 and compiled in Cmake 3.10 and VS2013 programmed with C++, and i've got a line after compiling with Cmake before "Configuration done" saying that"GuiSupportQt not found." i ignored it and generated solution then i gone to VS2013 to compile the solution provided by Cmake , i didn't find my project after opening solution in VS2013, i found only the common 2 projects that are named ALL_BUILD and ZERO_CHECK.
For more info, i've compiled before a non Gui project (3d vtk visualisation with vtk rendered without Qt) which is my own homework project and i've got a successful results which means in my opinion that the problem appears exactly when i compile a project that uses Qt considering that my Qt-VTK are compiled before with Cmake and built with VS2013 without any errors.
This is the code of Qt project sample that i used to test :
https://vtk.org/Wiki/VTK/Examples/Cxx/Qt/RenderWindowUISingleInheritance
This is what i get when i try to compile it with Cmake :
The C compiler identification is MSVC 18.0.21005.1
The CXX compiler identification is MSVC 18.0.21005.1
Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/cl.exe
Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/cl.exe -- works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/cl.exe
Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/cl.exe -- works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Detecting CXX compile features
Detecting CXX compile features - done
VTK_VERSION: 7.1.1
GuiSupportQt not found.
Configuring done
Generating done
After looking a while i found out another tricky solution to evade problems since i had Vtk visualisation part work fine and i work on windows, so i just sent parameters via command in cmd using Qt gui and then Vtk project compiled exe file will take parameters in execution (iso-value,data folder name..ect) in argv[] array then launch it in a new window, so i didn't have to compile Qt project with Cmake.

CMake build Tensorflow C++ on Windows 10 Error : Test COMPILER_OPT_ARCH_NATIVE_SUPPORTED - failed

I want to build Tensorflow C++ on Windows 10 using CMake. However I cannot pass the COMPILER_OPT_ARCH_NATIVE_SUPPORTED test, which resulting in failed building attempts. Here is my open issue on tf github repo: https://github.com/tensorflow/tensorflow/issues/24076, which has received no response thus why I am asking on stackoverflow and hopefully someone here can enlighten me. I am running out of ideas now. I have tried Python 3.5 and 3.6, visual studio 2017 and 2015. All with no success.
System information
OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Windows 10
TensorFlow installed from (source or binary): source
TensorFlow version: the latest version
Python version: 3.6
Bazel version (if compiling from source): I am using CMake
GCC/Compiler version (if compiling from source): gcc 6.30
CUDA/cuDNN version: Installing only the CPU version
I am also using Microsoft Visual Studio Community 2017 Version 15.9.3, btw
Describe the problem
I am following the "Step by step Windows Build" from https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/cmake. However, at step 3, I can't seem to pass Performing Test COMPILER_OPT_ARCH_NATIVE_SUPPORTED, which resulting failed building process.
Provide the exact sequence of commands / steps that you executed before running into the problem
PS C:\Users\bw\tensorflow\tensorflow\contrib\cmake\build> cmake .. -A x64 -Thost=x64 -DCMAKE_BUILD_TYPE=Release `
>> -DSWIG_EXECUTABLE='C:\Program Files\swigwin-3.0.12\swig.exe' `
>> -DPYTHON_EXECUTABLE='C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\python.exe' `
>> -DPYTHON_LIBRARIES='C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\libs\python36.lib'
-- Building for: Visual Studio 15 2017
CMake Warning at CMakeLists.txt:9 (message):
Your current cmake generator is set to use 32 bit toolset architecture.
This may cause "compiler out of heap space" errors when building. Consider
using the flag -Thost=x64 when running cmake.
-- The C compiler identification is MSVC 19.16.27024.1
-- The CXX compiler identification is MSVC 19.16.27024.1
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/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/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/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
-- Performing Test COMPILER_OPT_ARCH_NATIVE_SUPPORTED
-- Performing Test COMPILER_OPT_ARCH_NATIVE_SUPPORTED - Failed
-- Performing Test MSVC_OPENMP_SUPPORT
-- Performing Test MSVC_OPENMP_SUPPORT - Success
-- Found PythonInterp: C:/Program Files (x86)/Microsoft Visual Studio/Shared/Python36_64/python.exe (found version "3.6.7")
-- Found PythonLibs: optimized;C:/Program Files (x86)/Microsoft Visual Studio/Shared/Python36_64/libs/python36.lib;debug;C:/Program Files (x86)/Microsoft Visual Studio/Shared/Python36_64/libs/python36_d.lib (found version "3.6.7")
-- Found SWIG: C:/Program Files/swigwin-3.0.12/swig.exe (found version "3.0.12")
CMake Error at tf_python.cmake:811 (string):
string sub-command REPLACE requires at least four arguments.
Call Stack (most recent call first):
CMakeLists.txt:583 (include)
CMake Error at tf_python.cmake:812 (string):
string sub-command REPLACE requires at least four arguments.
Call Stack (most recent call first):
CMakeLists.txt:583 (include)
CMake Error at tf_python.cmake:813 (string):
string sub-command REPLACE requires at least four arguments.
Call Stack (most recent call first):
CMakeLists.txt:583 (include)
-- Configuring incomplete, errors occurred!
See also "C:/Users/bw/tensorflow/tensorflow/contrib/cmake/build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/bw/tensorflow/tensorflow/contrib/cmake/build/CMakeFiles/CMakeError.log".
Any other info / logs
CMakeOutput.log: https://www.dropbox.com/s/7fweyunxdbmxa1k/CMakeOutput.log?dl=0
CMakeError.log: https://www.dropbox.com/s/tucx0tl6346kdpd/CMakeError.log?dl=0
The first line of the guide states:
CMAKE build is deprecated for TensorFlow. Please use bazel to build TF for all platforms. For details, see the TensorFlow install guide.
Apparently you need to use a release version that is known to build correctly via CMAKE on Windows. Probably should switch to the recommended build system if you want to build the latest code.
Looking at the CMakeLists.txt file for this project shows that Performing Test COMPILER_OPT_ARCH_NATIVE_SUPPORTED - Failed is the step where it checks if the compiler accepts the -march=native flag. It doesn't, see this fix https://github.com/tensorflow/tensorflow/issues/8724#issuecomment-289326917.
The actual errors are due to a scripting issue in tf_python.cmake that cannot properly parse one of the source files. It seems to me that the issues are unrelated.

CMake with Boost library Windows 10 Library not found correctly

Like many others i have problems using boost libraries with windows. On Ubuntu 16.04 it works all very well with libboost-all-dev but on windows i have many problems.
I try to build a cryptonote application which i can compile completely without any errors under linux. But i need also windows binaries so i did the steps to install the following tools:
Visual Studio 2013 (vc120)
CMake 3.10.1
Python 3.6.4
Boost 1.58
For boost i did the following steps:
Installing boost from binary
Run bootstrap.bat
Run b2 install
Run bjam install "--with-some-libs"
Nothing works. The cryptonote throws me an error that some but not all libraries could not be found.
I tried to set the BOOST_ROOT, BOOST_LIBRARY_DIRS, BOOST_INCLUDE_DIRS -> Nothing.
What i did wrong? The error i get from cmake is this:
-- Building for: Visual Studio 12 2013
-- The C compiler identification is MSVC 18.0.31101.0
-- The CXX compiler identification is MSVC 18.0.31101.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - not found
-- Found Threads: TRUE
CMake Error at C:/Program Files/CMake/share/cmake-3.10/Modules/FindBoost.cmake:1928 (message):
Unable to find the requested Boost libraries.
Boost version: 1.58.0
Boost include path: C:/local/boost_1_58_0
Could not find the following static Boost libraries:
boost_system
boost_filesystem
boost_thread
boost_date_time
boost_chrono
boost_regex
boost_serialization
boost_program_options
Some (but not all) of the required Boost libraries were found. You may
need to install these additional Boost libraries. Alternatively, set
BOOST_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT
to the location of Boost.
Call Stack (most recent call first):
CMakeLists.txt:113 (find_package)
-- WARNING: Git was not found!
-- Found PythonInterp: C:/Users/chris/AppData/Local/Programs/Python/Python36-32/python.exe (found version "3.6.4")
CMake Warning in CMakeLists.txt:
CMAKE_SKIP_INSTALL_RULES was enabled even though installation rules have
been specified
-- Configuring incomplete, errors occurred!
See also "C:/Users/chris/Documents/GitHub/cryptonote/build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/chris/Documents/GitHub/cryptonote/build/CMakeFiles/CMakeError.log".
Maybe someone can help to fix this issue ?
Greetings
Ok finally i've found a solution after reading many, many and many more pages on the internet.
The solution is really simple. After downloading the boost package and installing it (or building from source) you just need the following two parts:
Open your CMD (cmd.exe)
switch to your installation directory of boost (example C:\local\boost_1_58_0)
Just run the following commands:
bootstrap.bat
b2 link=static runtime-link=static release stage
This will create all librarys static and makes it useable for cmake.
This solution works for me and made me able to build the needed package.
Thanks for all helpers
Or you could just tell boost which compiler to use by adding
toolset=msvc-12.0
(for MS 2013 v12, etc.)
to the b2 command line :-)

Windows CMake Won't Compile Test Program

I'm trying to setup a C/C++ environment using CLion, but CMake isn't able to compile the test program:
C:\Users\corey\.CLion2016.3\system\cygwin_cmake\bin\cmake.exe -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - Unix Makefiles" /cygdrive/c/Users/corey/ClionProjects/demo
-- The C compiler identification is MSVC 18.0.31101.0
-- The CXX compiler identification is MSVC 18.0.31101.0
-- Check for working C compiler: /cygdrive/c/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/cl.exe
-- Check for working C compiler: /cygdrive/c/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/cl.exe -- broken
CMake Error at /cygdrive/c/Users/corey/.CLion2016.3/system/cygwin_cmake/share/cmake-3.6.2/Modules/CMakeTestCCompiler.cmake:61 (message):
The C compiler "/cygdrive/c/Program Files (x86)/Microsoft Visual Studio
12.0/VC/bin/cl.exe" is not able to compile a simple test program.
It fails with the following output:
Change Dir: /cygdrive/c/Users/corey/ClionProjects/demo/cmake-build-debug/CMakeFiles/CMakeTmp
Run Build Command:"/cygdrive/c/D/dmd2/windows/bin/make.exe"
"cmTC_2a8fc/fast"
f CMakeFiles/cmTC_2a8fc.dir/build.make CMakeFiles/cmTC_2a8fc.dir/build
Error: 'f' not found
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:2 (project)
-- Configuring incomplete, errors occurred!
See also "/cygdrive/c/Users/corey/ClionProjects/demo/cmake-build-debug/CMakeFiles/CMakeOutput.log".
See also "/cygdrive/c/Users/corey/ClionProjects/demo/cmake-build-debug/CMakeFiles/CMakeError.log".
I'm running Windows 10 and VC 12.0 (Visual Studio 2013?). I've tried setting CLion up to use cygwin cmake instead of the built in version, and I've tried reinstalling all relevant tools, with no success.
Figured it out - missed it the first few times in the output - I have D lang DMD installed, which has it's own make.exe for whatever reason. CMake was selecting this make executable for whatever reason by default, rather than the one in cygwin. Either uninstalling DMD or manually configuring CMake to use the cygwin make fixes the issue.

Cmake Visual Studio 2015 Identification Unknown

So basically i am trying to use Cmake to build a project i am working on, the project uses GLEW (as shared library). GLEW links to both glu32.lib and opengl32.lib. They are added to the CMakelists.txt of glew on the target_link_libraries call like:
target_link_libraries(glew PUBLIC opengl32 glu32)
When i try to generate code for using the viusal studio compiler (2015 Community). I get problems with CMake adding the link libraries to the Visual studio project with -lopengl32 and -lglue32. This is wrong since visual studio cant handle this and gives met the following error when trying to compile:
LINK : warning LNK4044: unrecognized option '/lglu32.lib';
LINK : warning LNK4044: unrecognized option '/lopengl32.lib';
The output of running the Visual Studio Generator is:
C:\Project\build>cmake .. -G "Visual Studio 14 2015 Win64"
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
-- 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
-- Found OpenGL: opengl32
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Project/build
The following two lines:
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
seem quite odd to me since it is able to run the Visual Studio compiler. I read something about this being the cause of the invalid -l addition to the linker.
Is there anyone that had this problem and knows how to solve it?
Thanks in advance
CMakeError.txt:
Compilation of the C compiler identification source "CMakeCCompilerId.c" did not produce an executable in "C:Project/build/CMakeFiles/3.5.2/CompilerIdC".
Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" did not produce an executable in "C:/Project/build/CMakeFiles/3.5.2/CompilerIdCXX".
After spending some time searching i fixed it! The actual path of the project i was trying to build contained a SPACE in its path. Appearantly CMake can't handle this.