How to link torch in leveldb, and use leveldb in YCSB-cpp?

I want use torch(C++ version of pytorch) in leveldb, and link leveldb in YCSB-cpp to benchmark it, I can not install torch and leveldb in system path, because I using public sever. I got some error when I bind leveldb in YCSB-cpp.

I put torch in CMakeLists.txt like this, try to find python and torch, and set Torch path flag:

find_package(PythonInterp REQUIRED)
find_package(Torch REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}")
add_library(leveldb "")
target_sources(leveldb
  PRIVATE
    "${PROJECT_BINARY_DIR}/${LEVELDB_PORT_CONFIG_DIR}/port_config.h"
    "db/builder.cc"

after target_sources, I use target_link_libraries to link torch libraries:

# Needed by port_stdcxx.h
find_package(Threads REQUIRED)
target_link_libraries(leveldb Threads::Threads)

target_link_libraries(leveldb "${TORCH_LIBRARIES}")

I use this command to pass in libtorch, and build:

cmake -DCMAKE_PREFIX_PATH=/absolute/path/to/libtorch ..
make -j 24

I use this shell to bind leveldb in YCSB-cpp

make BIND_LEVELDB=1 EXTRA_CXXFLAGS=-I/path/to/leveldb/include \ EXTRA_LDFLAGS="-I/path/to/leveldb/include -L/path/to/leveldb/build -lleveldb"

but I got this error message:

CC       leveldb/leveldb_db.o
  CC       core/basic_db.o
  CC       core/db_factory.o
  CC       core/measurements.o
  CC       core/ycsbc.o
  CC       core/acknowledged_counter_generator.o
  CC       core/core_workload.o
/usr/bin/ld: leveldb/leveldb_db.o: in function `ycsbc::LeveldbDB::Init()':
leveldb_db.cc:(.text+0x40ee): undefined reference to `leveldb::DestroyDB(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, leveldb::Options const&)'
/usr/bin/ld: leveldb_db.cc:(.text+0x4133): undefined reference to `leveldb::DB::Open(leveldb::Options const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, leveldb::DB**)'
/usr/bin/ld: leveldb/leveldb_db.o: in function `ycsbc::LeveldbDB::InsertSingleEntry(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::vector<ycsbc::DB::Field, std::allocator<ycsbc::DB::Field> >&) [clone .cold]':
leveldb_db.cc:(.text.unlikely+0x33): undefined reference to `leveldb::Status::ToString[abi:cxx11]() const'
/usr/bin/ld: leveldb/leveldb_db.o: in function `ycsbc::LeveldbDB::DeleteSingleEntry(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) [clone .cold]':
leveldb_db.cc:(.text.unlikely+0x181): undefined reference to `leveldb::Status::ToString[abi:cxx11]() const'
/usr/bin/ld: leveldb/leveldb_db.o: in function `ycsbc::LeveldbDB::UpdateSingleEntry(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::vector<ycsbc::DB::Field, std::allocator<ycsbc::DB::Field> >&) [clone .cold]':
leveldb_db.cc:(.text.unlikely+0x30a): undefined reference to `leveldb::Status::ToString[abi:cxx11]() const'
/usr/bin/ld: leveldb_db.cc:(.text.unlikely+0x3c8): undefined reference to `leveldb::Status::ToString[abi:cxx11]() const'
/usr/bin/ld: leveldb/leveldb_db.o: in function `ycsbc::LeveldbDB::ReadSingleEntry(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const*, std::vector<ycsbc::DB::Field, std::allocator<ycsbc::DB::Field> >&) [clone .cold]':
leveldb_db.cc:(.text.unlikely+0x622): undefined reference to `leveldb::Status::ToString[abi:cxx11]() const'
/usr/bin/ld: leveldb/leveldb_db.o:leveldb_db.cc:(.text.unlikely+0xa08): more undefined references to `leveldb::Status::ToString[abi:cxx11]() const' follow
collect2: error: ld returned 1 exit status
make: *** [Makefile:89: ycsb] Error 1

Here are some possible reasons:

  1. I misplaced target_link_libraries(leveldb “${TORCH_LIBRARIES}”)
  2. I should pass in torch link to in YCSB-cpp too, just like snappy