LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 608|回复: 4

请问一下:怎样静态编译一个程序啊!

[复制链接]
发表于 2004-5-28 12:07:01 | 显示全部楼层 |阅读模式
我这个程序用到了SDL,SDL_image,SDL_ttf!
急需知道!!!
万分感谢!!!
发表于 2004-5-28 15:37:29 | 显示全部楼层
编译时加上
--enable-static-link,--disable-shared参数
 楼主| 发表于 2004-5-28 15:51:39 | 显示全部楼层

不行啊!

gcc -lSDL -L/usr/lib -lpthread -lSDL_image -lSDL_ttf --enable-static-link,--disable-shared ball.c

错误如下:
/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../../crt1.o(.text+0x18): In function `_start':../sysdeps/i386/elf/start.S:77: undefined reference to `main'
 楼主| 发表于 2004-5-28 15:54:04 | 显示全部楼层

re

但是如果不静态编译,也就是说后面的参数不要:  --enable-static-link,--disable-shared(不要)

则没有错误(不过这只是动态编译)
但是我现在急需静态编译!
谢谢指教!
发表于 2004-5-28 17:08:32 | 显示全部楼层
用gcc -static编译试试看。编译之前要安装好glibc的static包。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表