Chinaunix首页 | 论坛 | 博客
  • 博客访问: 96472
  • 博文数量: 34
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 12
  • 用 户 组: 普通用户
  • 注册时间: 2013-12-18 15:36
文章分类

全部博文(34)

文章存档

2014年(8)

2013年(26)

我的朋友

分类: LINUX

2014-01-03 16:32:07

test.c文件内容:
#include
  2 int main()
  3 {
  4         printf("Hello world\n");
  5         return 0;
  6 }

应 用: [xl.xue@localhost test]$ arm-linux-gcc -nostartfiles -nostdlib -static -L/usr/local/arm/2.95.3/arm-linux/lib -lc -lgcc test.c
报错误信息:
test.c:1:20: error: stdio.h : No such file or directory
test.c: In function 'main':
test.c:4: warning: incompatible implicit declaration of built-in function 'printf'

应用: [xl.xue@localhost test]$ arm-linux-gcc -nostartfiles -nostdlib -static -L/usr/local/arm/2.95.3/arm-linux/lib test.c -lc -lgcc
可以正确通过.
主要原因是: 当编译连接test.c时,遇到printf没有定义时,停止编译连接,查找后面的编译连接,可是否存在定义。所以上面的那种方式查不到printf定义报错。


把程序编译成静态
gcc -static foo.c
阅读(3029) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~