Hallo HaBo,
ich möchte mit CMake ein C++-Projekt kompilieren welches boost 1.56.00 benutzt. Boost habe ich kompiliert und nach lib/ im Projektverzeichnis gepackt. Auf dem System (Ubuntu) ist über die Paketverwaltung noch boost 1.48.00 installiert (kann nicht entfernt werden, andere Sachen hängen davon ab). In meiner CMakeLists.txt setze ich folgendes:
Wenn ich jedoch folgendes ausführe:
Kommt raus "1_48", also die alte Version. Wie bringe ich CMake bei ausschließlich in meinem lib/-Verzeichnis zu suchen?
In der falschen Bibliothek,
bad_alloc
ich möchte mit CMake ein C++-Projekt kompilieren welches boost 1.56.00 benutzt. Boost habe ich kompiliert und nach lib/ im Projektverzeichnis gepackt. Auf dem System (Ubuntu) ist über die Paketverwaltung noch boost 1.48.00 installiert (kann nicht entfernt werden, andere Sachen hängen davon ab). In meiner CMakeLists.txt setze ich folgendes:
Code:
set(BOOST_ROOT "lib/boost_1_56_00/")
set(Boost_INCLUDE_DIR "lib/boost_1_56_00/boost/")
set(Boost_LIBRARY_DIRS "lib/boost_1_56_00/lib/")
set(Boost_NO_SYSTEM_PATHS ON)
Wenn ich jedoch folgendes ausführe:
Code:
#include <iostream>
#include "boost/version.hpp"
using namespace std;
int main() {
cout << "Using boost version " << BOOST_LIB_VERSION << endl;
return 0;
}
Kommt raus "1_48", also die alte Version. Wie bringe ich CMake bei ausschließlich in meinem lib/-Verzeichnis zu suchen?
Code:
cmake_minimum_required (VERSION 2.6)
project (GAME CXX)
set(CMAKE_CXX_COMPILER "g++-4.7")
# no-as-needed required
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wl,--no-as-needed")
# The version number.
set (GAME_VERSION_MAJOR 1)
set (GAME_VERSION_MINOR 0)
# configure a header file to pass some of the CMake settings
# to the source code
configure_file (
"${PROJECT_SOURCE_DIR}/GAMECMakeConfig.h.in"
"${PROJECT_BINARY_DIR}/GAMECMakeConfig.h"
)
file(GLOB_RECURSE GAME_SOURCES "src/*.cpp")
# add the binary tree to the search path for include files
# so that we will find GAMEConfig.h
include_directories("${PROJECT_BINARY_DIR}")
include_directories("${PROJECT_SOURCE_DIR}/include/")
include_directories("${PROJECT_SOURCE_DIR}/lib/include/")
include_directories("${PROJECT_SOURCE_DIR}/lib/boost_1_56_00/boost/")
add_subdirectory (include)
# get all libraries
#set(CMAKE_LIBRARY_PATH "lib/" "lib/boost_1_54_0/installed/lib/")
set(CMAKE_LIBRARY_PATH "lib/" "lib/boost_1_56_0/lib/")
set(BOOST_ROOT "lib/boost_1_56_00/")
set(Boost_INCLUDE_DIR "lib/boost_1_56_00/boost/")
set(Boost_LIBRARY_DIRS "lib/boost_1_56_00/lib/")
set(Boost_NO_SYSTEM_PATHS ON)
#find_package(Boost 1.56 HINTS "lib/boost_1_56_00/")
find_library(GL NAMES GL gl HINTS "/usr/lib/x86_64-linux-gnu/mesa/libGL.so")
find_library(GLU NAMES GLU glu libglu)
find_library(Xxf86vm NAMES Xxf86vm HINTS "/usr/lib/libXxf86vm.so")
find_library(Xrandr NAMES Xrandr)
find_library(Xext NAMES Xext)
find_library(Irrlicht libIrrlicht.a)
find_library(Filesystem NAMES libboost_filesystem.so)
find_library(ProgramOptions NAMES libboost_program_options.so)
find_library(System NAMES libboost_system.so)
find_library(Thread NAMES libboost_thread.so)
# add the executable
add_executable(GAME.exe main.cpp ${GAME_SOURCES})
target_link_libraries (GAME.exe ${GL} ${GLU} ${X11} ${Xxf86vm} ${Xrandr} ${Xext} ${Irrlicht} ${System} ${Filesystem} ${Thread} ${ProgramOptions})
In der falschen Bibliothek,
bad_alloc