Firefly开源社区

编译linux下hello world应用程序通不过,怎么搞?

80

积分

0

威望

0

贡献

技术小白

积分
80
发表于 2015-3-11 19:35:25     
编译环境已经打好了,内核kernel和initrd都能编译出来。



后来想试试写个hello world编译下,放到板子上跑,却发现居然编译都有问题了。
我是用的cmake,生成的makefile,反复查过,是没有问题的。

下面这个是用的4.7的,说找不到cdefs.h,我find了也确实是没有的。
lr@ubuntu:~/RK3288/codes/hello/build$ make
Scanning dependencies of target hello_exe
[100%] Building C object CMakeFiles/hello_exe.dir/hello.c.o
In file included from /home/lr/RK3288/codes/hello/hello.c:3:0:
/home/lr/RK3288/SDK/prebuilts/gcc/linux-x86/arm/arm-eabi-4.7/bin/../lib/gcc/arm-eabi/4.7/include-fixed/stdio.h:50:23: fatal error: sys/cdefs.h: No such file or directory
compilation terminated.
CMakeFiles/hello_exe.dir/build.make:54: recipe for target 'CMakeFiles/hello_exe.dir/hello.c.o' failed
make[2]: *** [CMakeFiles/hello_exe.dir/hello.c.o] Error 1
CMakeFiles/Makefile2:60: recipe for target 'CMakeFiles/hello_exe.dir/all' failed
make[1]: *** [CMakeFiles/hello_exe.dir/all] Error 2
Makefile:72: recipe for target 'all' failed
make: *** [all] Error 2

下面是4.6的,说找不到stdio.h
lr@ubuntu:~/RK3288/codes/hello/build$ make
Scanning dependencies of target hello_exe
[100%] Building C object CMakeFiles/hello_exe.dir/hello.c.o
/home/lr/RK3288/codes/hello/hello.c:3:19: fatal error: stdio.h: No such file or directory
compilation terminated.
CMakeFiles/hello_exe.dir/build.make:54: recipe for target 'CMakeFiles/hello_exe.dir/hello.c.o' failed
make[2]: *** [CMakeFiles/hello_exe.dir/hello.c.o] Error 1
CMakeFiles/Makefile2:60: recipe for target 'CMakeFiles/hello_exe.dir/all' failed
make[1]: *** [CMakeFiles/hello_exe.dir/all] Error 2
Makefile:72: recipe for target 'all' failed
make: *** [all] Error 2

内核那些代码可以编译通过,那说明编译环境是没问题的,不知道为什么这么简单的hello world编译通不过。





回复

使用道具 举报

122

积分

1

威望

0

贡献

社区版主

Rank: 7Rank: 7Rank: 7

积分
122
发表于 2015-3-12 10:32:02     
指定交叉编译工具链时,可能也要指定包含头文件位置C_INCLUDE_PATH ,库文件位置LIBRARY_PATH之类的。因为这不是系统默认的编译器。
回复

使用道具 举报

122

积分

1

威望

0

贡献

社区版主

Rank: 7Rank: 7Rank: 7

积分
122
发表于 2015-3-12 10:33:10     
要不你直在在开发板上编译吧,就跟在PC上效果一样。啥都不用写。
回复

使用道具 举报

80

积分

0

威望

0

贡献

技术小白

积分
80
发表于 2015-3-12 10:59:51     
error结构体 发表于 2015-3-12 10:33
要不你直在在开发板上编译吧,就跟在PC上效果一样。啥都不用写。

谢谢回复

你说不用交叉编译环境直接在目标板上编译应用程序,这个倒是可以试一试。
以前从来都是用交叉编译环境做开发,毕竟PC很强大,而目标板性能差距很大。
都说RK3288性能强大,我马上试试,要是可以,就先这样用着。
回复

使用道具 举报

80

积分

0

威望

0

贡献

技术小白

积分
80
发表于 2015-3-12 14:02:46     
error结构体 发表于 2015-3-12 10:33
要不你直在在开发板上编译吧,就跟在PC上效果一样。啥都不用写。

试了下,在盒子上没有自带的编译器
我是直接打的gcc的命令,不知道对不对。

sudo apt-get install gcc 不行,报错,似乎是下载是找不到目标IP。
sudo apt-get instll update也不行
sudo apt-get instll upgrade也不行

倒是发现
sudo apt-get instll vim 可以,vim装好也是可以用的。

最后看了下社区,发现贴子
http://developer.t-firefly.com/thread-793-1-2.html

提到编译器要用gcc-linaro-arm-linux-gnueabihf-4.7-2013.02-01-20130221_linux
,一会再试试。
回复

使用道具 举报

80

积分

0

威望

0

贡献

技术小白

积分
80
发表于 2015-3-12 14:18:43     
可以,顺利的在RK3288上输出了hello world
回复

使用道具 举报

11

积分

0

威望

0

贡献

技术小白

积分
11
发表于 2018-5-14 11:24:48     
请问我在开发板上如何安装这个编译器
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

友情链接 : 爱板网 电子发烧友论坛 云汉电子社区 粤ICP备14022046号-2
快速回复 返回顶部 返回列表