Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

希望增加.cmake文件,方便使用CMakelist编译时引用 #70

Open
pd-unprofessional opened this issue Jan 18, 2024 · 1 comment

Comments

@pd-unprofessional
Copy link

pd-unprofessional commented Jan 18, 2024

在编译生成静态库之后,使用CMakelist链接静态库时,必须按顺序链接。才能编译成功,顺序如下:
add_executable(test src/main.cpp)
target_link_libraries(test
${catkin_LIBRARIES}
${LIB_DIR_ARCH}/cpp-tbox/lib/libtbox_main.a
${LIB_DIR_ARCH}/cpp-tbox/lib/libtbox_log.a
${LIB_DIR_ARCH}/cpp-tbox/lib/libtbox_terminal.a
${LIB_DIR_ARCH}/cpp-tbox/lib/libtbox_network.a
${LIB_DIR_ARCH}/cpp-tbox/lib/libtbox_eventx.a
${LIB_DIR_ARCH}/cpp-tbox/lib/libtbox_event.a
${LIB_DIR_ARCH}/cpp-tbox/lib/libtbox_util.a
${LIB_DIR_ARCH}/cpp-tbox/lib/libtbox_base.a
-lpthread
-ldl
)

@pd-unprofessional pd-unprofessional changed the title 需要增加.cmake 希望增加.cmake文件,方便使用CMakelist编译时引用 Jan 18, 2024
@xkf321
Copy link

xkf321 commented Jan 29, 2024

target_link_libraries增加 -Wl,--start-group 和-Wl,--end-group参数可以实现随意顺序链接
set(TBOX_LIB
${TBOX_LIB_PATH}/libtbox_terminal.a
${TBOX_LIB_PATH}/libtbox_network.a
${TBOX_LIB_PATH}/libtbox_log.a
${TBOX_LIB_PATH}/libtbox_util.a
${TBOX_LIB_PATH}/libtbox_base.a
${TBOX_LIB_PATH}/libtbox_main.a
${TBOX_LIB_PATH}/libtbox_alarm.a
${TBOX_LIB_PATH}/libtbox_coroutine.a
${TBOX_LIB_PATH}/libtbox_crypto.a
${TBOX_LIB_PATH}/libtbox_dbus.a
${TBOX_LIB_PATH}/libtbox_flow.a
${TBOX_LIB_PATH}/libtbox_eventx.a
${TBOX_LIB_PATH}/libtbox_http.a
${TBOX_LIB_PATH}/libtbox_jsonrpc.a
${TBOX_LIB_PATH}/libtbox_mqtt.a
${TBOX_LIB_PATH}/libtbox_event.a

)
target_link_libraries(${TARGETFILE}
-Wl,--start-group
pthread
dl
file
${crypto_LIB}
${TBOX_LIB}
-Wl,--end-group)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants