adding symbols: DSO missing from command line collect2: error: ld returned 1 exi...
🚨 错误信息
/data/gerrit/workspace_AIBox_repo/Vendor/IC_NM_OrinX/aarch64--glibc--stable-2022.08-1/bin/../lib/gcc/aarch64-buildroot-linux-gnu/11.3.0/../../../../aarch64-buildroot-linux-gnu/bin/ld: CMakeFiles/SenseMemoryService.dir/SenseMemoryService.cpp.obj: undefined reference to symbol '_ZN9senseauto11sensememory18SenseMemory_Logger4InitENS0_20SenseMemory_LogLevelE'
/data/gerrit/workspace_AIBox_repo/Vendor/IC_NM_OrinX/aarch64--glibc--stable-2022.08-1/bin/../lib/gcc/aarch64-buildroot-linux-gnu/11.3.0/../../../../aarch64-buildroot-linux-gnu/bin/ld: /data/gerrit/workspace_AIBox_repo/AICore/IC_NM_SenseMemory/output/linux_orin/lib/libsenseauto_infrastructure.so: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit statu
🤖 AI解决方案
/data/gerrit/workspace_AIBox_repo/Vendor/IC_NM_OrinX/aarch64--glibc--stable-2022.08-1/bin/../lib/gcc/aarch64-buildroot-linux-gnu/11.3.0/../../../../aarch64-buildroot-linux-gnu/bin/ld: CMakeFiles/SenseMemoryService.dir/SenseMemoryService.cpp.obj: undefined reference to symbol '_ZN9senseauto11sensememory18SenseMemory_Logger4InitENS0_20SenseMemory_LogLevelE'
/data/gerrit/workspace_AIBox_repo/Vendor/IC_NM_OrinX/aarch64--glibc--stable-2022.08-1/bin/../lib/gcc/aarch64-buildroot-linux-gnu/11.3.0/../../../../aarch64-buildroot-linux-gnu/bin/ld: /data/gerrit/workspace_AIBox_repo/AICore/IC_NM_SenseMemory/output/linux_orin/lib/libsenseauto_infrastructure.so: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
错误翻译:
链接器 (ld) 报告:在 SenseMemoryService.cpp.obj 中找不到对符号 '_ZN9senseauto11sensememory18SenseMemory_Logger4InitENS0_20SenseMemory_LogLevelE' 的定义。
链接器 (ld) 报告:在链接库 'libsenseauto_infrastructure.so' 时,找不到所需的符号。
链接器 (ld) 报告:链接器返回了 1 个错误状态。
原因分析:
链接器在构建 SenseMemoryService 可执行文件时,找不到 SenseMemory_Logger::Init 函数的定义。这通常是因为实现该函数的库(libsenseauto_infrastructure.so)没有被正确地链接到目标可执行文件中。
解决方案:
在您的构建系统中(例如 CMake),确保 libsenseauto_infrastructure.so 库被添加到 SenseMemoryService 的链接目标中。
如果您使用 CMake,请检查您的 target_link_libraries() 命令,确保它包含了 libsenseauto_infrastructure。例如:
# 假设 SenseMemoryService 是您的可执行目标
add_executable(SenseMemoryService SenseMemoryService.cpp)
# 找到并链接 libsenseauto_infrastructure 库
find_library(SENSEAUTO_INFRASTRUCTURE_LIB senseauto_infrastructure PATHS ${CMAKE_BINARY_DIR}/output/linux_orin/lib) # 根据您的库路径调整
if(SENSEAUTO_INFRASTRUCTURE_LIB)
target_link_libraries(SenseMemoryService PRIVATE ${SENSEAUTO_INFRASTRUCTURE_LIB})
else()
message(FATAL_ERROR "libsenseauto_infrastructure.so not found!")
endif()如果
libsenseauto_infrastructure.so 是一个静态库,则命令会有所不同,请确保您链接的是正确的库文件。
预防措施:
- 依赖管理:在项目中使用清晰的依赖管理机制,确保所有必需的库在构建时都能被正确找到和链接。
- 构建脚本审查:定期审查构建脚本(如 CMakeLists.txt、Makefile 等),确保所有目标都正确地指定了其依赖项。