Closed gaowayne closed 3 years ago
hello guys, I have fixed the build issue by modify CMakeLists.txt file sequence and static link and dynamic link. when running. I found another error, SPDK register macro is not built into my application, that cause it failed to init scheduler list.
SPDK_SCHEDULER_REGISTER(scheduler);
/*
static void attribute((constructor)) _spdk_schedulerregister ## scheduler (void) \ { \ _spdk_scheduler_list_add(&scheduler); \ } \
I adjust CMakelists.txt. now schedule is registered well now. but bdev malloc RPC method cannot be registered.
SPDK_RPC_REGISTER("bdev_malloc_create", rpc_bdev_malloc_create, SPDK_RPC_RUNTIME)
[root@cyp03 build]# nm hello_boostasio | grep rpc_bdev_malloc_create [root@cyp03 build]#
[root@cyp03 examples]# nm hello_bdev | grep rpc_bdev_malloc_create 0000000000408255 t rpc_bdev_malloc_create 000000000040843d t rpc_register_rpc_bdev_malloc_create [root@cyp03 examples]#
below is my latest CMakeLists.txt
cmake_minimum_required(VERSION 2.8.9)
#set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -O0 -ggdb3 -Wall")
set (CMAKE_CXX_FLAGS "-std=c++14 -O0 -ggdb3 -DBOOST_LOG_DYN_LINK -DBOOST_LOG_USE_NATIVE_SYSLOG")
project (hello_boostasio)
#add_definitions(-Wno-builtin-macro-redefined --verbose )
add_definitions(--verbose )
include_directories(${CMAKE_SOURCE_DIR}/../../../dpdk/build/include
${CMAKE_SOURCE_DIR}/../../../include
${CMAKE_SOURCE_DIR}/../../../build/include)
#link_directories(${CMAKE_SOURCE_DIR}/../../../dpdk/lib
# ${CMAKE_SOURCE_DIR}/../../../lib)
link_directories(/root/nvme_disk/boostasiospdk/spdk/dpdk/build/lib
/root/nvme_disk/boostasiospdk/spdk/build/lib)
#dpdk spdk_trace
#set(COMMLIBS uuid numa pthread dl rt curl ssl pthread boost_program_options boost_log_setup boost_log boost_thread boost_system boost_filesystem librte_eal.so librte_cmdline.so librte_mbuf.so librte_mempool.so librte_mempool_ring.so librte_ring.so librte_pci.so librte_bus_pci.so librte_bus_vdev.so librte_compressdev.so librte_cryptodev.so librte_hash.so librte_kvargs.so spdk_env_dpdk spdk_env_dpdk_rpc spdk_nvme spdk_bdev spdk_notify spdk_util spdk_log spdk_sock spdk_event spdk_event_bdev spdk_thread spdk_conf spdk_rpc spdk_json spdk_util spdk_jsonrpc spdk_trace spdk_rpc)
set(DYNA_COMMLIBS uuid numa pthread dl rt curl ssl pthread boost_program_options boost_log_setup boost_log boost_thread boost_system boost_filesystem librte_eal.so librte_cmdline.so librte_mbuf.so librte_mempool.so librte_mempool_ring.so librte_ring.so librte_pci.so librte_bus_pci.so librte_bus_vdev.so librte_compressdev.so librte_cryptodev.so librte_hash.so librte_kvargs.so)
set(STAT_COMMLIBS
libspdk_rpc.a
libspdk_accel.a libspdk_bdev_ftl.a libspdk_bdev_passthru.a libspdk_blob_bdev.a libspdk_env_dpdk_rpc.a libspdk_event_nvmf.a libspdk_init.a libspdk_lvol.a libspdk_scsi.a libspdk_ut_mock.a
libspdk_accel_ioat.a libspdk_bdev_gpt.a libspdk_bdev_raid.a libspdk_blobfs.a libspdk_event.a libspdk_event_scsi.a libspdk_ioat.a libspdk_nbd.a libspdk_sock.a libspdk_vhost.a
libspdk_bdev.a libspdk_bdev_lvol.a libspdk_bdev_split.a libspdk_blobfs_bdev.a libspdk_event_accel.a libspdk_event_sock.a libspdk_iscsi.a libspdk_notify.a libspdk_sock_posix.a libspdk_virtio.a
libspdk_bdev_aio.a libspdk_bdev_malloc.a libspdk_bdev_virtio.a libspdk_conf.a libspdk_event_bdev.a libspdk_event_vhost.a libspdk_json.a libspdk_nvme.a libspdk_thread.a libspdk_vmd.a
libspdk_bdev_delay.a libspdk_bdev_null.a libspdk_bdev_zone_block.a libspdk_dma.a libspdk_event_iscsi.a libspdk_event_vmd.a libspdk_jsonrpc.a libspdk_nvmf.a libspdk_trace.a
libspdk_bdev_error.a libspdk_bdev_nvme.a libspdk_blob.a libspdk_env_dpdk.a libspdk_event_nbd.a libspdk_ftl.a libspdk_log.a libspdk_rpc.a libspdk_util.a )
set (HELLOBOOSTASIO_SRC
hello_boostasio.cc
)
add_library(spdkapplib OBJECT ${HELLOBOOSTASIO_SRC})
link_libraries(hello_boostasio ${STAT_COMMLIBS})
add_executable(hello_boostasio $<TARGET_OBJECTS:spdkapplib> main.cc)
#add_executable(hello_boostasio ${HELLOBOOSTASIO_SRC})
target_link_libraries(hello_boostasio ${DYNA_COMMLIBS})
Please consider using pkg-config to generate your list of libraries. https://spdk.io/doc/pkgconfig.html
You may also try pretending Q= to the SPDK make line to compare your cmake build with what SPDK build system is linking.
@gaowayne The missing symbol rpc_bdev_malloc_create
is used in constructor function and probably it was ignored by the linker. SPDK docs say that when static libraries are linked, it is needed to use -Wl,--whole-archive
linker option. Please refer to https://spdk.io/doc/libraries.html
Bug report
I want to use CMakeLists and cmake to build my simple hello_bdev example SPDK app application. But I suffer the link error related with SPDK app framework event core code even I am pretty sure I add spdk_event into CmakeLists.txt file.
Expected Behavior
I can build my simple SPDK example app with Cmakelists.txt.
Current Behavior
the link error is below
Possible Solution
Steps to Reproduce
include_directories(${CMAKE_SOURCE_DIR}/../../../dpdk/include ${CMAKE_SOURCE_DIR}/../../../include)
link_directories(${CMAKE_SOURCE_DIR}/../../../dpdk/lib ${CMAKE_SOURCE_DIR}/../../../lib)
dpdk spdk_trace
set(COMMLIBS uuid numa pthread dl rt curl ssl pthread librte_eal.so librte_cmdline.so librte_mbuf.so librte_mempool.so librte_mempool_ring.so librte_ring.so librte_pci.so librte_bus_pci.so librte_bus_vdev.so librte_compressdev.so librte_cryptodev.so librte_hash.so librte_kvargs.so spdk_env_dpdk spdk_env_dpdk_rpc spdk_nvme spdk_bdev spdk_notify spdk_util spdk_log spdk_sock spdk_event spdk_event_bdev spdk_thread spdk_conf spdk_rpc spdk_json spdk_util spdk_jsonrpc spdk_trace)
set (HELLOBOOSTASIO_SRC hello_boostasio.c )
add_executable(hello_boostasio ${HELLOBOOSTASIO_SRC})
target_link_libraries(hello_boostasio ${COMMLIBS})
[root@cyp03 lib]# nm /usr/local/lib/libspdk_event.a | grep spdk_rpc U spdk_rpc_finish U spdk_rpc_get_state U spdk_rpc_initialize U spdk_rpc_register_alias_deprecated U spdk_rpc_register_method U spdk_rpc_set_state U spdk_rpc_register_alias_deprecated U spdk_rpc_register_method U spdk_rpc_register_alias_deprecated U spdk_rpc_register_method
[root@cyp03 lib]# nm /usr/local/lib/libspdk_eventbdev.a | grep spdk 0000000000000000 d g_spdk_subsystem_bdev 000000000000007b t g_spdk_subsystem_bdev_register U spdk_add_subsystem U spdk_add_subsystem_depend U spdk_bdev_finish U spdk_bdev_initialize U spdk_bdev_subsystem_config_json U spdk_subsystem_fini_next U spdk_subsystem_init_next