0

I tried to compile the jemalloc demo using cmake/And here is my initial cmake code.

//brew install jemalloc

in CMakeLists

link_directories(/usr/local/lib)
target_link_libraries(${PROJECT_NAME} jemalloc)

in cpp

#include <jemalloc/jemalloc.h>

Error: cannot include <jemalloc/jemalloc.h>

... ok, fine. I try that.

in CMakeLists

include_directories(/usr/local/include)

link_directories(/usr/local/lib)
target_link_libraries(${PROJECT_NAME} jemalloc)

make

[build] ld: library not found for -ljemalloc
[build] clang: error: linker command failed with exit code 1 (use -v to see invocation)
[build] make[3]: *** [demo] Error 1
[build] make[2]: *** [CMakeFiles/demo.dir/all] Error 2
[build] make[1]: *** [CMakeFiles/demo.dir/rule] Error 2

I don't know what to do?

I tried to compile from the command line.

clang -std=c++11 demo.cpp -ljemalloc

It's ok....

Maybe I can put some pictures.

enter image description here

enter image description here

alazysun
  • 1
  • 1
  • 2
    Where exactly is the .so (or .a) file located? Btw: In general it's preferred to specify link/include dirs per target using `target_link_directories`/`target_include_directories` – fabian Feb 06 '21 at 21:40
  • @fabian /usr/local/lib – alazysun Feb 07 '21 at 03:55

0 Answers0