cocalele / PureFlash

A ServerSAN storage system designed for flash device
GNU General Public License v3.0
97 stars 29 forks source link

编译报错/usr/bin/ld: pf_zk_client.cpp:(.text+0x1e2): undefined reference to `zookeeper_init' #41

Open zphj1987 opened 7 months ago

zphj1987 commented 7 months ago

按照编译说明里面: https://github.com/cocalele/PureFlash/blob/master/build_and_run.txt 步骤一步步操作,x86架构,ubuntu22.04环境

在 4) run ninja to do build $ ninja 步骤的时候会出错,提示如下:

[53/55] Linking CXX executable bin/pfs
FAILED: bin/pfs
: && /usr/bin/c++ -Wall -Wconversion -Wno-sign-compare  -fms-extensions -Wno-variadic-macros -Wno-format-truncation -I/usr/include -D_XOPEN_SOURCE  -O3 -DNDEBUG -rdynamic pfs/CMakeFiles/pfs.dir/src/pf_cluster.cpp.o pfs/CMakeFiles/pfs.dir/src/pf_flash_store.cpp.o pfs/CMakeFiles/pfs.dir/src/pf_main.cpp.o pfs/CMakeFiles/pfs.dir/src/pf_s5message.cpp.o pfs/CMakeFiles/pfs.dir/src/pf_server.cpp.o pfs/CMakeFiles/pfs.dir/src/pf_dispatcher.cpp.o pfs/CMakeFiles/pfs.dir/src/pf_md5.cpp.o pfs/CMakeFiles/pfs.dir/src/pf_redolog.cpp.o pfs/CMakeFiles/pfs.dir/src/pf_block_tray.cpp.o pfs/CMakeFiles/pfs.dir/src/pf_replica.cpp.o pfs/CMakeFiles/pfs.dir/src/pf_restful_server.cpp.o pfs/CMakeFiles/pfs.dir/src/pf_restful_api.cpp.o pfs/CMakeFiles/pfs.dir/src/pf_volume.cpp.o pfs/CMakeFiles/pfs.dir/src/pf_error_handler.cpp.o pfs/CMakeFiles/pfs.dir/src/pf_replicator.cpp.o pfs/CMakeFiles/pfs.dir/src/pf_bitmap.cpp.o pfs/CMakeFiles/pfs.dir/src/pf_bgtask_manager.cpp.o pfs/CMakeFiles/pfs.dir/src/pf_scrub.cpp.o pfs/CMakeFiles/pfs.dir/src/pf_atslock.cpp.o pfs/CMakeFiles/pfs.dir/src/pf_spdk_engine.cpp.o pfs/CMakeFiles/pfs.dir/src/pf_rdma_server.cpp.o pfs/CMakeFiles/pfs.dir/__/thirdParty/mongoose/mongoose.c.o -o bin/pfs -L/root/PureFlash/pre_build_libs/ubuntu_22.04_x86_64   -L/root/PureFlash/build_deb/bin   -L/root/PureFlash/thirdParty/spdk/build/lib   -L/root/PureFlash/thirdParty/spdk/dpdk/build/lib -lrdmacm  -libverbs  -lpthread  -lzookeeper_mt  -lhashtable  -luuid  -lspdk_nvme  -lspdk_env_dpdk  -lspdk_util  -lspdk_log  -lspdk_sock  -lspdk_trace  -lspdk_json  -lspdk_jsonrpc  -lspdk_rpc  -lrte_eal  -lrte_mempool  -lrte_ring  -lrte_telemetry  -lrte_kvargs  -lrte_pci  -lrte_bus_pci  -lrte_mempool_ring  bin/libs5common.a  -laio  -lcurl  ../thirdParty/isa-l_crypto/.libs/libisal_crypto.a  -Wl,-Bstatic  -lsgutils2  -Wl,-Bdynamic  -ldl  -lrdmacm  -libverbs  -lpthread && cd /root/PureFlash/build_deb/pfs && cp -rpfu /root/PureFlash/pfs/pfs_template.conf /root/PureFlash/build_deb
/usr/bin/ld: bin/libs5common.a(pf_zk_client.cpp.o): in function `PfZkClient::init(char const*, int, char const*)':
pf_zk_client.cpp:(.text+0x1a2): undefined reference to `zoo_set_debug_level'
/usr/bin/ld: pf_zk_client.cpp:(.text+0x1e2): undefined reference to `zookeeper_init'
/usr/bin/ld: pf_zk_client.cpp:(.text+0x1f2): undefined reference to `ZOO_CONNECTED_STATE'
/usr/bin/ld: pf_zk_client.cpp:(.text+0x214): undefined reference to `zoo_state'
/usr/bin/ld: bin/libs5common.a(pf_zk_client.cpp.o): in function `PfZkClient::~PfZkClient()':
pf_zk_client.cpp:(.text+0x2b1): undefined reference to `zookeeper_close'
/usr/bin/ld: bin/libs5common.a(pf_zk_client.cpp.o): in function `PfZkClient::get_data_port[abi:cxx11](int, int)':
pf_zk_client.cpp:(.text+0x394): undefined reference to `zoo_get_children'
/usr/bin/ld: bin/libs5common.a(pf_zk_client.cpp.o): in function `PfZkClient::watch_disk_owner(char const*, std::function<void (char const*)>)':
pf_zk_client.cpp:(.text+0x6e0): undefined reference to `zoo_wget_children'
/usr/bin/ld: pf_zk_client.cpp:(.text+0x7fe): undefined reference to `zoo_get'
/usr/bin/ld: bin/libs5common.a(pf_zk_client.cpp.o): in function `PfZkClient::create_node(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, char const*) [clone .localalias]':
pf_zk_client.cpp:(.text+0xc4b): undefined reference to `zoo_exists'
/usr/bin/ld: pf_zk_client.cpp:(.text+0xdb6): undefined reference to `ZOO_EPHEMERAL'
/usr/bin/ld: pf_zk_client.cpp:(.text+0xde0): undefined reference to `ZOO_OPEN_ACL_UNSAFE'
/usr/bin/ld: pf_zk_client.cpp:(.text+0xdf1): undefined reference to `zoo_create'
/usr/bin/ld: pf_zk_client.cpp:(.text+0xe5b): undefined reference to `zoo_exists'
/usr/bin/ld: bin/libs5common.a(pf_zk_client.cpp.o): in function `PfZkClient::wait_lock(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char const*)':
pf_zk_client.cpp:(.text+0x158f): undefined reference to `ZOO_EPHEMERAL_SEQUENTIAL'
/usr/bin/ld: pf_zk_client.cpp:(.text+0x15cb): undefined reference to `ZOO_OPEN_ACL_UNSAFE'
/usr/bin/ld: pf_zk_client.cpp:(.text+0x15f0): undefined reference to `zoo_create'
/usr/bin/ld: pf_zk_client.cpp:(.text+0x186e): undefined reference to `zoo_wget_children'
/usr/bin/ld: pf_zk_client.cpp:(.text+0x1d95): undefined reference to `zoo_remove_watches'
/usr/bin/ld: bin/libs5common.a(pf_zk_client.cpp.o): in function `std::_Function_handler<void (), PfZkClient::wait_lock(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char const*)::{lambda()#1}>::_M_invoke(std::_Any_data const&)':
pf_zk_client.cpp:(.text+0x68): undefined reference to `deallocate_String_vector'
/usr/bin/ld: bin/libs5common.a(pf_zk_client.cpp.o): in function `std::_Function_handler<void (), PfZkClient::get_data_port[abi:cxx11](int, int)::{lambda()#1}>::_M_invoke(std::_Any_data const&)':
pf_zk_client.cpp:(.text+0x78): undefined reference to `deallocate_String_vector'
/usr/bin/ld: bin/libs5common.a(pf_zk_client.cpp.o): in function `std::_Function_handler<void (), PfZkClient::watch_disk_owner(char const*, std::function<void (char const*)>)::{lambda()#1}>::_M_invoke(std::_Any_data const&)':
pf_zk_client.cpp:(.text+0x88): undefined reference to `deallocate_String_vector'
/usr/bin/ld: bin/libs5common.a(pf_zk_client.cpp.o): in function `PfZkClient::delete_node(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
pf_zk_client.cpp:(.text+0x310): undefined reference to `zoo_delete'
/usr/bin/ld: bin/libs5common.a(pf_client_api.cpp.o): in function `get_master_conductor_ip[abi:cxx11](char const*, char const*)':
pf_client_api.cpp:(.text+0x6a5d): undefined reference to `zoo_set_debug_level'
/usr/bin/ld: pf_client_api.cpp:(.text+0x6a74): undefined reference to `zookeeper_init'
/usr/bin/ld: pf_client_api.cpp:(.text+0x6b32): undefined reference to `zoo_state'
/usr/bin/ld: pf_client_api.cpp:(.text+0x6b3b): undefined reference to `ZOO_CONNECTED_STATE'
/usr/bin/ld: pf_client_api.cpp:(.text+0x6b7a): undefined reference to `zoo_get_children'
/usr/bin/ld: pf_client_api.cpp:(.text+0x6c73): undefined reference to `zoo_get'
/usr/bin/ld: bin/libs5common.a(pf_client_api.cpp.o): in function `std::_Function_handler<void (), get_master_conductor_ip[abi:cxx11](char const*, char const*)::{lambda()#1}>::_M_invoke(std::_Any_data const&)':
pf_client_api.cpp:(.text+0x518): undefined reference to `zookeeper_close'
/usr/bin/ld: bin/libs5common.a(pf_client_api.cpp.o): in function `std::_Function_handler<void (), get_master_conductor_ip[abi:cxx11](char const*, char const*)::{lambda()#2}>::_M_invoke(std::_Any_data const&)':
pf_client_api.cpp:(.text+0x528): undefined reference to `deallocate_String_vector'
collect2: error: ld returned 1 exit status
[54/55] Building CXX object common/CMakeFiles/pfdd.dir/src/pf_pfdd.cpp.o
/root/PureFlash/common/src/pf_pfdd.cpp: In function ‘int main(int, char**)’:
/root/PureFlash/common/src/pf_pfdd.cpp:266:17: warning: unused variable ‘offset_in_file’ [-Wunused-variable]
  266 |         int64_t offset_in_file = 0;
      |                 ^~~~~~~~~~~~~~
ninja: build stopped: subcommand failed.
zphj1987 commented 7 months ago

补充:

3) run cmake to generate ninja scripts
  # cd PureFlash;
  # export PUREFLASH_HOME=`pwd`
  # mkdir build_deb; cd build_deb
  # cmake -GNinja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=/usr/local/bin/ninja ..

The above command will generate scripts for Debug build. To do a release build, run command:
  # cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_MAKE_PROGRAM=/usr/local/bin/ninja ..

第三步的时候:

 cmake -GNinja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=/usr/local/bin/ninja ..

然后运行ninja 这样没问题 如果运行

  # cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_MAKE_PROGRAM=/usr/local/bin/ninja ..

再运行ninja 就异常了

cocalele commented 7 months ago

感谢反馈,我们之前确实很少用release模式编译,包括测试也是用的debug模式。