隐藏符号 __dso_handle 问题

在项目移植过程中,作者遇到了动态库编译错误,详细记录了解决过程。问题源于使用-nostdlib选项,导致系统启动文件未被使用。通过调整编译链接选项,最终成功解决了编译问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

这几天要给项目做移植,重写了下Makfile。项目原是使用autoconf配置的,但在新环境下对autoconf的支持不好。

Makefile编写基本按autoconf生成的Makefile来的,编译选项等等,但是在使用动态库时报了下面的错误:

/usr/bin/ld: client: hidden symbol `__dso_handle' in /usr/lib/gcc/i486-linux-gnu/4.4.3/crtbegin.o is referenced by DSO
/usr/bin/ld: final link failed: Nonrepresentable section on output

 

网上搜到的结果都是是gcc/g++的binUtils的问题,编译动态库需要使用gcc/g++ -shared而不能直接使用ld,而我的Makefile就是这么做的,结果还是出现了这个问题.

逐步取得编译连接选项,发现取得-nostdlib后即可成功编译,看来是这个的问题.

看了下gcc的文档,使用该选项是是不是用系统启动文件(不知道怎么翻译)的,这就说明除非你在代码里自己处理crt启动问题,否则不要用这个选项:

-nostdlib
Do not use the standard system startup files or libraries when linking. No startup files and only the libraries you specify are passed to the linker, and options specifying linkage of the system libraries, such as -static-libgcc or -shared-libgcc, are ignored.

 

转载于:https://www.cnblogs.com/D3Hunter/p/3346805.html

## remove /home/lubuntu/workspace/RTOS_Beacon_ZhuJiaFuJia/cortex_a/output.64/out ## LD /home/lubuntu/workspace/RTOS_Beacon_ZhuJiaFuJia/cortex_a/output/out/amba_svc.elf LD_MAP /home/lubuntu/workspace/RTOS_Beacon_ZhuJiaFuJia/cortex_a/output/out/amba_svc.map /usr/local/gcc-arm-none-eabi-10-2020-q4-major-amba-A_R-Profile_r1_20210623/bin/arm-none-eabi-ld: /home/lubuntu/workspace/RTOS_Beacon_ZhuJiaFuJia/cortex_a/vendors/ambarella/lib/cv2fs/libview_rear_pt.a(logical_adapter_truck_rear.o): in function `logical_adapter::cmsTrackRearMove::~cmsTrackRearMove()': logical_adapter_truck_rear.cpp:(.text+0x2bc): undefined reference to `operator delete(void*, unsigned int)' /usr/local/gcc-arm-none-eabi-10-2020-q4-major-amba-A_R-Profile_r1_20210623/bin/arm-none-eabi-ld: /home/lubuntu/workspace/RTOS_Beacon_ZhuJiaFuJia/cortex_a/vendors/ambarella/lib/cv2fs/libview_rear_pt.a(truck_rear_tyre_pt.o): in function `view_init': truck_rear_tyre_pt.cpp:(.text+0x1dc): undefined reference to `__dso_handle' /usr/local/gcc-arm-none-eabi-10-2020-q4-major-amba-A_R-Profile_r1_20210623/bin/arm-none-eabi-ld: truck_rear_tyre_pt.cpp:(.text+0x1e0): undefined reference to `__dso_handle' /usr/local/gcc-arm-none-eabi-10-2020-q4-major-amba-A_R-Profile_r1_20210623/bin/arm-none-eabi-ld: truck_rear_tyre_pt.cpp:(.text+0x1f0): undefined reference to `__aeabi_atexit' /usr/local/gcc-arm-none-eabi-10-2020-q4-major-amba-A_R-Profile_r1_20210623/bin/arm-none-eabi-ld: /home/lubuntu/workspace/RTOS_Beacon_ZhuJiaFuJia/cortex_a/vendors/ambarella/lib/cv2fs/libview_rear_pt.a(camera_rotation_cotr.o): in function `camera_rot_cotransform::PositionRotation::~PositionRotation()': camera_rotation_cotr.cpp:(.text+0x10): undefined reference to `operator delete(void*, unsigned int)' /usr/local/gcc-arm-none-eabi-10-2020-q4-major-amba-A_R-Profile_r1_20210623/bin/arm-none-eabi-ld: /home/lubuntu/workspace/RTOS_Beacon_ZhuJiaFuJia/cortex_a/vendors/ambarella/lib/cv2fs/libview_rear_pt.a(trace.o): in function `trace_track::TraceTrack::~TraceTrack()': trace.cpp:(.text+0x10): undefined reference to `operator delete(void*, unsigned int)' /usr/local/gcc-arm-none-eabi-10-2020-q4-major-amba-A_R-Profile_r1_20210623/bin/arm-none-eabi-ld: /home/lubuntu/workspace/RTOS_Beacon_ZhuJiaFuJia/cortex_a/output/out/amba_svc.elf: hidden symbol `__dso_handle' isn't defined /usr/local/gcc-arm-none-eabi-10-2020-q4-major-amba-A_R-Profile_r1_20210623/bin/arm-none-eabi-ld: final link failed: bad value /home/lubuntu/workspace/RTOS_Beacon_ZhuJiaFuJia/cortex_a/svc/Makefile.Amba:176: recipe for target '/home/lubuntu/workspace/RTOS_Beacon_ZhuJiaFuJia/cortex_a/output/out/amba_svc.elf' failed make[1]: *** [/home/lubuntu/workspace/RTOS_Beacon_ZhuJiaFuJia/cortex_a/output/out/amba_svc.elf] Error 1 make[1]: Leaving directory '/home/lubuntu/workspace/RTOS_Beacon_ZhuJiaFuJia/cortex_a/output' Makefile:190: recipe for target 'sub-make' failed make: *** [sub-make] Error 2
03-18
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值