11 ~~~> openWRT compile CLI package error undefined reference to symbol'dlsym@@GLIBC_2.2.5'

This blog records the solutions to errors in compiling the OpenWRT x86-64 sysupgrade package, and memo records.
Add Attended sysUpgrade package, make menuconfig

  -> Base system 
  --> <*> auc............ Attended sysUpgrade CLI (EXPERIMENTAL)

The compilation error message is as follows:

.......
[100%] Linking C executable auc
/home/robot/OpenWrt/LS1046A-19.07/staging_dir/toolchain-x86_64_gcc-8.3.0_glibc/lib/gcc/x86_64-openwrt-linux-gnu/8.3.0/../../../../x86_64-openwrt-linux-gnu/bin/ld: CMakeFiles/auc.dir/auc.c.o: undefined reference to symbol 'dlsym@@GLIBC_2.2.5'
/home/robot/OpenWrt/LS1046A-19.07/staging_dir/toolchain-x86_64_gcc-8.3.0_glibc/lib/gcc/x86_64-openwrt-linux-gnu/8.3.0/../../../../x86_64-openwrt-linux-gnu/bin/ld: /home/robot/OpenWrt/LS1046A-19.07/staging_dir/toolchain-x86_64_gcc-8.3.0_glibc/x86_64-openwrt-linux-gnu/bin/../../../toolchain-x86_64_gcc-8.3.0_glibc/lib64/libdl.so.2: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
CMakeFiles/auc.dir/build.make:84: recipe for target 'auc' failed
make[6]: *** [auc] Error 1
........

Resolution process:


# (1) 进入auc的编译文件夹中
$ cd build_dir/target-x86_64_glibc/auc-0.1.4/

# (2) 修改CMakeList.txt 文件,增加链接依赖库 dl
$ vim CMakeLists.txt
ADD_EXECUTABLE(auc auc.c)
TARGET_LINK_LIBRARIES(auc uci ubox ubus uclient blobmsg_json ${
    
    json} -ldl #增加内容 -ldl )
INSTALL(TARGETS auc RUNTIME DESTINATION sbin)

Reason explanation:
call the dynamic link library, rely on the glibc library dlsym, check man dlsym to clearly point out that the link parameter -ldl is required, as shown in the following figure:
Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_38387929/article/details/113922765