2017-09-22 4 views
0

verknüpfen Ich versuche, die Jemalloc-Bibliothek in meine Anwendung zur Build-Zeit zu verknüpfen, indem ich es als generische Implementierung verwende. Nach https://github.com/jemalloc/jemalloc/wiki/Getting-Started die Verknüpfung Fahnen zu verwenden sind:Wie jemalloc shared library mithilfe von cmake

-L`jemalloc-config --libdir` -Wl,-rpath,`jemalloc-config --libdir` -ljemalloc `jemalloc-config --libs` 

Also habe ich folgendes CMakeLists.txt:

cmake_minimum_required(VERSION 2.8.12.2) 
project(widget) 
include_directories(include) 
file(GLOB SOURCES "src/*.cpp") 
add_executable(widget ${SOURCES}) 
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L`jemalloc-config --libdir` -Wl,-rpath,`jemalloc-config --libdir` -ljemalloc `jemalloc-config --libs`") 

Aber wenn ich make tun das folgende Fehler erhalte ich:

Linking CXX executable widget 
c++: error: `jemalloc-config: No such file or directory 
c++: error: unrecognized command line option ‘--libdir`’ 
c++: error: unrecognized command line option ‘--libdir`’ 
c++: error: unrecognized command line option ‘--libs`’ 
make[2]: *** [widget] Error 1 
make[1]: *** [CMakeFiles/widget.dir/all] Error 2 

Antwort

1

execute_process() Befehl ist dein Freund. Verwenden Sie es, um jemalloc-config Executable auszuführen und dann seine Ausgabe in CMake-Variablen zu setzen.

Verwandte Themen