LinuxSir.cn,穿越时空的Linuxsir!

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

惊报消息!gcc不能编译非开源程序!

[复制链接]
发表于 2010-7-23 20:26:07 | 显示全部楼层 |阅读模式
如果我说gcc不能编译非开源程序,你们肯定都不相信,不过……请看下面代码:
root [ ~ ]# cat > dummy.c << "EOF"
> main()
> {
> return 0;
> }
> EOF
root [ ~ ]# cc -v dummy.c
使用内建 specs。
目标:i686-pc-linux-gnu
配置为:../gcc-4.1.2/configure --prefix=/usr --libexecdir=/usr/lib --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-languages=c,c++
线程模型:posix
gcc 版本 4.1.2
/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/cc1 -quiet -v dummy.c -quiet -dumpbase dummy.c -mtune=pentiumpro -auxbase dummy -version -o /tmp/ccMK4Ih4.s
忽略不存在的目录“/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/../../../../i686-pc-linux-gnu/include”
#include "..." 搜索从这里开始:
#include <...> 搜索从这里开始:
/usr/local/include
/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include
/usr/include
搜索列表结束。
GNU C 版本 4.1.2 (i686-pc-linux-gnu)
        由 GNU C 版本 4.1.2 编译。
GGC 准则:--param ggc-min-expand=46 --param ggc-min-heapsize=31063
Compiler executable checksum: ead8d85f961af071e52c6ea261304d8b
as -V -Qy -o /tmp/ccE5qyD6.o /tmp/ccMK4Ih4.s
GNU assembler version 2.17 (i686-pc-linux-gnu) using BFD version 2.17
/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/collect2 --eh-frame-hdr -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 /usr/lib/gcc/i686-pc-linux-gnu/4.1.2/../../../crt1.o /usr/lib/gcc/i686-pc-linux-gnu/4.1.2/../../../crti.o /usr/lib/gcc/i686-pc-linux-gnu/4.1.2/crtbegin.o -L/usr/lib/gcc/i686-pc-linux-gnu/4.1.2 -L/usr/lib/gcc/i686-pc-linux-gnu/4.1.2 -L/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/../../.. /tmp/ccE5qyD6.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/i686-pc-linux-gnu/4.1.2/crtend.o /usr/lib/gcc/i686-pc-linux-gnu/4.1.2/../../../crtn.o

尤其看
/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/collect2 --eh-frame-hdr -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 /usr/lib/gcc/i686-pc-linux-gnu/4.1.2/../../../crt1.o /usr/lib/gcc/i686-pc-linux-gnu/4.1.2/../../../crti.o /usr/lib/gcc/i686-pc-linux-gnu/4.1.2/crtbegin.o -L/usr/lib/gcc/i686-pc-linux-gnu/4.1.2 -L/usr/lib/gcc/i686-pc-linux-gnu/4.1.2 -L/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/../../.. /tmp/ccE5qyD6.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/i686-pc-linux-gnu/4.1.2/crtend.o /usr/lib/gcc/i686-pc-linux-gnu/4.1.2/../../../crtn.o

他连接到了一些gcc自带的.o文件。
不过……gcc是开源软件,符合GPL标准,所以……

如果一个程序闭源,用gcc编译,则会包括GPL代码:crt*.o,而那就必须开源。
发表于 2010-7-23 21:52:14 | 显示全部楼层
叹号,请去掉,很容易让人误以为 lz 是小朋友。

GPL 律师杰作,不要假定自己真能读懂。
www.fsf.org www.gnu.org 有针对大众指引:

http://www.gnu.org/licenses/gpl-faq.html
http://www.gnu.org/licenses/gpl-faq.html#CanIUseGPLToolsForNF
Can I use GPL-covered editors such as GNU Emacs to develop non-free programs? Can I use GPL-covered tools such as GCC to compile them?

    Yes, because the copyright on the editors and tools does not cover the code you write. Using them does not place any restrictions, legally, on the license you use for your code.

    Some programs copy parts of themselves into the output for technical reasons—for example, Bison copies a standard parser program into its output file. In such cases, the copied text in the output is covered by the same license that covers it in the source code. Meanwhile, the part of the output which is derived from the program's input inherits the copyright status of the input.

    As it happens, Bison can also be used to develop non-free programs. This is because we decided to explicitly permit the use of the Bison standard parser program in Bison output files without restriction. We made the decision because there were other tools comparable to Bison which already permitted use for non-free programs.

http://www.gnu.org/licenses/gpl-faq.html#LibGCCException
Where can I learn more about the GCC Runtime Library Exception?

    The GCC Runtime Library Exception covers libgcc, libstdc++, libfortran, libgomp, libdecnumber, and other libraries distributed with GCC. The exception is meant to allow people to distribute programs compiled with GCC under terms of their choice, even when parts of these libraries are included in the executable as part of the compilation process. To learn more, please read our FAQ about the GCC Runtime Library Exception.

http://www.gnu.org/licenses/gcc-exception-faq.html 请通读全文
回复 支持 反对

使用道具 举报

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

本版积分规则

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