So I've got boost installed in C:\Program Files\boost_1_47_0\, with the library files in ./stage/lib/ and include files in ./boost/*
So I set an environment variable, BOOST_ROOT to C:\Program Files\boost_1_47_0 and run cmake on my project. I get errors that it can't find the requested boost libraries (math_c99, program_options, unit_test_framework).
This is odd, since I have the .lib files for all of them in BOOST_ROOT\stage\lib, and the include files are all there too.
I even added a SET(BOOST_LIBRARYDIR ... according to this question but still no luck. Any idea what gives?
Try to add the line
SET(Boost_ADDITIONAL_VERSIONS "1.47" "1.47.0")
before calling find_package.
Related
I'm trying to build kenlm which uses boost. The version of boost already installed on the system seems incompatible or too old or broken.
I have successfully built a copy of boost in my ~/local directory. I would like to tell cmake to use the boost headers found under ~/local/include and the libraries in ~/local/lib instead. However I can't see how to tell cmake to look at my custom path for libraries or headers. I've tried setting LD_LIBRARY_PATH to ~/local/lib:$LD_LIBRARY_PATH. Is there an equivalent variable for include path as well? I haven't been able to find one.
If there is no way to do this with just environment flags, I've been trying to edit the CMakeLists.txt file but haven't had much success. I tried editing in my include path but it still uses whatever find_package(Boost ..) finds which is the /usr/include header.
When i try to run cmake to build a project where i include the SFML library i get the following Error: SFML found but version too low (requested: 2.4, found: 1.x.x)
I downloaded only the source of the newest Version of the library (SFML-2.4.2). I than run cmake (with MinGW Makefiles) And build the binaries into the same folder.
I copied the FindSFML into an subfolder of my project.
After that i had the following folder structure
SFML-2.4.2\
cmake\
Modules\
FindSFML.cmake
CMakeFiles
doc
...
include
lib
src
..
sfml-games\
tetris\
cmake_modules\
FindSFML.cmake
CMakeLists.txt
main.cpp
tetris-build
...
My CMakeLists.txt contains the following stuff:
project(Tetris)
cmake_minimum_required(VERSION 2.8)
aux_source_directory(. SRC_LIST)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake_modules")
Find_package(SFML 2 REQUIRED system window graphics network audio)
include_directories(${SFML_INCLUDE_DIR})
add_executable(${PROJECT_NAME} ${SRC_LIST})
target_link_libraries(${PROJECT_NAME} ${SFML_LIBRARY})
I found that in cmake the entry CMAKE_INSTALL_PREFIX (which i dont get) is set to C:\Program Files (x86)\SFML so i put the library and the lib of SFML into C:\Program Files (x86)\SFML. (what is that CMAKE_INSTALL_PREFIX and should i realy always copy the library and lib folders into my C:\Program Files (x86)\ ??). Now my cmake runs through but when i try to compile the code i get a lot of undifined references to '_imp__....'
By the way on linux i just installed SFML via sudo apt-get install libsfml-dev and it works out of the box.
You're confusing things. CMAKE_INSTALL_PREFIX is the default location where to put SFML when you build the install target (i.e. running make install). This has nothing to do with your other issues.
You don't have to install SFML (or any other library) somewhere under C:\Program Files. That's completely up to you.
What I found to be rather neat is installing MinGW to C:\usr (or creating a symlink to your installation folder) and also use that path for CMAKE_INSTALL_PREFIX when building SFML.
This way MinGW should behave pretty much the way you're used to from Linux (i.e. not having to specify paths for include dir or libraries etc.).
As for your undefined reference errors, you should create a new question only asking for these (and then include at least a few of them), as they have nothing to do with the installation directory.
Right now I can only guess, but it's most likely due to you using the wrong CMake variables for the linker. You won't notice this on Linux, since SFML will be in the default search path (which will also happen if you use C:\usr as described above).
To try fixing this, use this line:
target_link_libraries(${PROJECT_NAME} ${SFML_LIBRARIES} ${SFML_DEPENDENCIES})
I have encountered what appears to be a CMake bug.
I have been migrating a large project to CMake and have all my libraries installed to /dir1/lib and /dir2/lib. Initially, the binary rPath contained both directories and compiled and ran fine. Seemingly randomly the executables stopped including /dir1/lib in their rPath. I have confirmed that CMake finds the libraries in the /dir1/lib because if I remove it from link_directories, it will not compile.
If I copy the libraries from /dir1/lib to /dir3/lib and replace the former with the latter in link_directories, /dir3/lib will appear in the rPath and the executable will run.
I have tried to isolate the problem. Clearing the CMake build files and cache did not help. Restarting did not help. I also created a simplified test case and CMake simply will not set the rPath for that specific directory.
I am running CMake 3.8.2 on OSX.
Is there any global CMake cache or settings I could reset?
I'm trying to fix the installation of a custom built Qt. I'm using the qt.conf from this very similar question. However, CMake 2.8.7 is still unable to find moc, uic, and rcc.
CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:97 (MESSAGE):
Could NOT find Qt4 (missing: QT_MOC_EXECUTABLE QT_RCC_EXECUTABLE
QT_UIC_EXECUTABLE) (found suitable exact version "4.8.1")
I have manually set the QT_QMAKE_EXECUTABLE variable to the correct value, namely B:/lib/vs10/Qt-4.8.1-VS10x64/bin/qmake.exe. After deploying the qt.conf file, qmake -v returns the correct path:
c:\>B:/lib/vs10/Qt-4.8.1-VS10x64/bin/qmake.exe -v
QMake version 2.01a
Using Qt version 4.8.1 in B:/lib/vs10/Qt-4.8.1-VS10x64/lib
qmake -query QT_INSTALL_PREFIX also returns the correct path. Note that I can't use environment variables because we need different Qt versions for different projects.
What am I missing?
You should set CMAKE_PREFIX_PATH to B:/lib/vs10/Qt-4.8.1-VS10x64/bin instead of setting QT_QMAKE_EXECUTABLE. It will help cmake to find all qt executables.
The problem was that they decided to make QT_BINARY_DIR a CACHE INTERNAL variable, which wasn't reset properly after changing qt.conf and deleting the QT_* variables in CMake. QT_BINARY_DIR is only reset if the path of the qmake.exe changes. After clearing the cache it worked.
The lessons I draw from this: Don't use CACHE INTERNAL, just FORCE and mark_as_advanced.
I have multiple versions of Boost installed (Windows 7/MinGW). I need to use a particular one (1.53.0).
I defined BOOST_ROOT in the CMakeFiles.txt file: SET(BOOST_ROOT C:/boost_1_53_0/), but I keep getting this error:
> cmake .
BOOST_ROOT=C:/boost_1_53_0/
CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindBoost.cmake:1191 (message):
Unable to find the requested Boost libraries.
Boost version: 1.48.0
Boost include path: C:/Boost/include/boost-1_48
Detected version of Boost is too old. Requested version was 1.53 (or
newer).
The following Boost libraries could not be found:
boost_filesystem
No Boost libraries were found. You may need to set BOOST_LIBRARYDIR to the
directory containing Boost libraries or BOOST_ROOT to the location of
Boost.
I also defined BOOST_ROOT as an environment variable, but with the same result.
Why is cmake still looking for the old version?
Try this:
cmake -DBOOST_ROOT=path
I also struggled with this same problem for a while. If this is the same issue that I had, then the problem is you aren't running the CMake configuration completely fresh without any cache. Once it runs once and finds the default installation (C:\Boost or /usr/include) it will continue to find that one regardless of the value of BOOST_ROOT. So make sure to completely delete any generated build files. Then set BOOST_ROOT to your desired separate installation and it should work fine.
This is also mentioned by jaor on the previously linked question: How can I get cmake to find my alternative boost installation?
If you are using a precompiled version of Boost libraries for Visual Studio, they come in a specific flavor of MSVC version and bitness. I needed to point CMake to that specific location - in my case, setting BOOST_ROOT to C:/local/boost_1_59_0 and BOOST_LIBRARYDIR to C:/local/boost_1_59_0/lib64-msvc-11.0 helped.