C语言常见编译错误与执行错误

hello: line 1: syntax error: unexpected word (expecting “)”)

编写fasync_jni应用程序放在Tiny210开发板上跑会出现如下错误:
这里写图片描述

然后编写一个最简单的hello world程序放在Tiny210开发板上跑也会出现类似这样的错误:hello: line 1: syntax error: unexpected word (expecting “)”)

解决办法:加上-static选项,arm-linux-gcc hello.c –static –o hello
貌似将库文件编译到应用程序里面之后就能执行。
另外放在哪个目录去执行也比较重要,最好放在根目录去执行。


/udisk # ./uevents /system/bin/sh: ./uevents: not found

问题解法同上,编译的时候加上–static


error: unknown type name ‘uint32_t’

如果在自己的头文件中有用到uint32_t,要在这些头文件中包含stdint.h


cannot open shared object file: No such file or directory

具体错误如下:
./rts5401_ft2: error while loading shared libraries: librtcr.so.1: cannot open shared object file: No such file or directory
也就是运行缺少动态链接库,在网上查了主要有3种方法:
1、用ln的方法将需要的so文件链接到/usr/lib或者/lib这两个默认的目录下边
ln -s /where/you/install/lib/*.so /usr/lib
sudo ldconfig
2、修改LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/where/you/install/lib:$LD_LIBRARY_PATH
sudo ldconfig
3、修改/etc/ld.so.conf
vim /etc/ld.so.conf
add [where you install lib]
sudo ldconfig

我采用第3种方法
在/etc/ld.so.conf.d目录下添加文件librtcr.conf,文件librtcr.conf文件中记录librtcr链接库文件的路径,添加完了之后使用sudo ldconfig来重新将库文件的路径加到系统路径下面。


make: * No rule to make target ` ‘, needed by xxx. Stop

基本上都是属于找不到所依赖的文件所导致的,所以应该去检测确保所依赖的文件是否真实存在。
很可能,很常见的一个现象就是,此处的,误写了多余的空格,导致被视为依赖文件,导致找不到,导致报此错误。
解决办法就很简单,去掉多余的空格即可。


field has incomplete type

linux下编译C++代码报错,报错信息”field has incomplete type”。这种问题一般都是在头文件对类或者结构体进行了前向声明,后面使用了该类定义了对象,导致编译报错。
原因在于前向声明类或者结构体,此时编译器还不知道定义,无法知道类内部成员,所以无法构造实例对象,因此前向声明的类或者结构体只能用来定义指针或者引用


function declaration isn’t a prototype

参考文章:function declaration isn’t a prototype
In C int foo() and int foo(void) are different functions. int foo() accepts an arbitrary number of arguments, while int foo(void) accepts 0 arguments. In C++ they mean the same thing. I suggest that you use void consistently when you mean no arguments.

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

luckywang1103

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值