Kar*_*ius 4 linker compiler-errors makefile cmake jemalloc
我试图在构建时将 jemalloc 库链接到我的应用程序中,使用它作为通用实现。根据https://github.com/jemalloc/jemalloc/wiki/Getting-Started,要使用的链接标志是:
\n\n-L`jemalloc-config --libdir` -Wl,-rpath,`jemalloc-config --libdir` -ljemalloc `jemalloc-config --libs`\nRun Code Online (Sandbox Code Playgroud)\n\n所以我做了以下CMakeLists.txt:
\n\ncmake_minimum_required(VERSION 2.8.12.2)\nproject(widget)\ninclude_directories(include)\nfile(GLOB SOURCES "src/*.cpp")\nadd_executable(widget ${SOURCES})\nset(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L`jemalloc-config --libdir` -Wl,-rpath,`jemalloc-config --libdir` -ljemalloc `jemalloc-config --libs`")\nRun Code Online (Sandbox Code Playgroud)\n\n但是当我这样做时,make我收到以下错误:
Linking CXX executable widget\nc++: error: `jemalloc-config: No such file or directory\nc++: error: unrecognized command line option \xe2\x80\x98--libdir`\xe2\x80\x99\nc++: error: unrecognized command line option \xe2\x80\x98--libdir`\xe2\x80\x99\nc++: error: unrecognized command line option \xe2\x80\x98--libs`\xe2\x80\x99\nmake[2]: *** [widget] Error 1\nmake[1]: *** [CMakeFiles/widget.dir/all] Error 2\nRun Code Online (Sandbox Code Playgroud)\n
对于后代来说,这仍然是谷歌上的第一个链接。
Jemalloc 附带 pkg-config 设置,可以像这样使用:
find_package(PkgConfig REQUIRED)
pkg_check_modules (JEMALLOC jemalloc)
pkg_search_module(JEMALLOC REQUIRED jemalloc)
include_directories(${JEMALLOC_INCLUDE_DIRS})
target_link_libraries(your_target_name ${JEMALLOC_LIBRARIES})
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4094 次 |
| 最近记录: |