隐式声明与内建函数 ‘exit’ 不兼容 解决方法 - [Linux]

本文记录了一名初学者从Windows转向Linux编程的过程。在使用C语言进行编程时遇到了关于函数exit隐式声明的问题,并详细探讨了解决方法,包括添加头文件stdlib.h。


版权声明 :转载时请以超链接形式标明文章原始出处和作者信息及本声明 http://dark0729.blogbus.com/logs/70629853.html

    初学linux编程,刚开学脱离windows。
    开学学习总不免会有些困难。慢慢习惯吧。
    从C开始学,开始学习linux编程。接下来再学习python。
    C语言,开发环境Eclipce+GCC。
    写的第一个程序是一个write函数的系统调用。结果出现问题了。在退出返回时,隐式声明与内建函数"exit“不兼容,偿试方法两种,一:注释exit函数,然后改用return语句,可以正常编译且执行。二:添加头文件,stdlib.h可以正常编译与执行。
查 看stdlib.h源代码,发现里面有exit函数的声明,extern void exit (int __status) __THROW __attribute__ ((__noreturn__));应该这个就是添加这个头文件的原因吧。在网上查到还有就是printf之类函数也会出现这个问题。

[ 36%] Linking C executable dmpSwitch /mydisk/mazhao/enterprise_gateway/staging_dir/marvell-tools-249.0/bin/../lib/gcc/aarch64-marvell-linux-gnu/7.3.0/../../../../aarch64-marvell-linux-gnu/bin/ld: warning: libfepCap.so.0, needed by /mydisk/mazhao/enterprise_gateway/build_dir/target-aarch64-marvell-linux-gnu-cn25g-vpp_v1/platform/fep/lib/libmm.so, not found (try using -rpath or -rpath-link) /mydisk/mazhao/enterprise_gateway/staging_dir/marvell-tools-249.0/bin/../lib/gcc/aarch64-marvell-linux-gnu/7.3.0/../../../../aarch64-marvell-linux-gnu/bin/ld: warning: libpcap.so.1, needed by /mydisk/mazhao/enterprise_gateway/build_dir/target-aarch64-marvell-linux-gnu-cn25g-vpp_v1/platform/fep/lib/libfepPacket.so, not found (try using -rpath or -rpath-link) CMakeFiles/dmpSwitch.dir/common/dalCommon.c.o: In function `devSysInfoCapGet': /mydisk/mazhao/enterprise_gateway/build_dir/target-aarch64-marvell-linux-gnu-cn25g-vpp_v1/dmpSwitch/common/dalCommon.c:341: undefined reference to `mmCapacityGetString' /mydisk/mazhao/enterprise_gateway/build_dir/target-aarch64-marvell-linux-gnu-cn25g-vpp_v1/dmpSwitch/common/dalCommon.c:353: undefined reference to `mmCapacityGetString' /mydisk/mazhao/enterprise_gateway/build_dir/target-aarch64-marvell-linux-gnu-cn25g-vpp_v1/dmpSwitch/common/dalCommon.c:365: undefined reference to `mmCapacityGetString' /mydisk/mazhao/enterprise_gateway/build_dir/target-aarch64-marvell-linux-gnu-cn25g-vpp_v1/dmpSwitch/common/dalCommon.c:377: undefined reference to `mmCapacityGetString' /mydisk/mazhao/enterprise_gateway/build_dir/target-aarch64-marvell-linux-gnu-cn25g-vpp_v1/dmpSwitch/common/dalCommon.c:389: undefined reference to `mmCapacityGetString' CMakeFiles/dmpSwitch.dir/common/dalCommon.c.o:/mydisk/mazhao/enterprise_gateway/build_dir/target-aarch64-marvell-linux-gnu-cn25g-vpp_v1/dmpSwitch/common/dalCommon.c:401: more undefined references to `mmCapacityGetString' follow /mydisk/mazhao/enterprise_gateway/build_dir/target-aarch64-marvell-linux-gnu-cn25g-vpp_v1/platform/fep/lib/libfepPacket.so: undefined reference to `fepCapStrGet' /mydisk/mazhao/enterprise_gateway/build_dir/target-aarch64-marvell-linux-gnu-cn25g-vpp_v1/platform/fep/lib/libmm.so: undefined reference to `fepCapDeInit' /mydisk/mazhao/enterprise_gateway/build_dir/target-aarch64-marvell-linux-gnu-cn25g-vpp_v1/platform/fep/lib/libmm.so: undefined reference to `fepCapInit' /mydisk/mazhao/enterprise_gateway/build_dir/target-aarch64-marvell-linux-gnu-cn25g-vpp_v1/platform/fep/lib/libfepPacket.so: undefined reference to `fepCapNumGet' collect2: error: ld returned 1 exit status 报错解析
最新发布
07-30
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值