sfu-dis / pibench-ep2

Benchmarking new Optane PMem-based persistent memory range indexes (VLDB 2022)
20 stars 6 forks source link

use `target_link_libraries` to add linker flags #16

Closed YalandHong closed 1 year ago

YalandHong commented 2 years ago

Hello,

You should not put -lpmemobj or other linker flags into set(CMAKE_CXX_FLAGS ...). Please use target_link_libraries instead.

We have encountered lots of undefined symbol errors during compilation. The so wrappers can't be correctly linked with libpmem, because the options are placed in wrong order.

Here's the output command from make VERBOSE=1:

/usr/bin/c++ -fPIC  -O0 -std=c++17 -lpmemobj -lpmem -ljemalloc -mrtm -pthread -O3 -DNDEBUG  -shared -Wl,-soname,libutree_pibench_wrapper.so -o src/libutree_pibench_wrapper.so CMakeFiles/utree_pibench_wrapper.dir/utree_wrapper.cpp.o

Refecence: c++ - Flag '-l' in CMAKE_CXX_FLAGS doesn't work - Stack Overflow What is the right order of linker flags in gcc? - Stack Overflow