开发者

How can I compile GCC as a static binary?

How can I compile the GCC Compiler so that I can pull the entire thing over to another system and use the program? I don't mind pulling in other files as well, but is there a way to gather all the required system libs as well? The OS and Arch will remain constant across th开发者_如何学Goe different systems, but one may contain Slackware where the other contains Debian.


Don't try to build it as a static binary. That's hopeless.

Instead, look into how cross compilers are built. Then do the same for your GCC except you will be building for the same CPU architecture. Build your binutils into /opt/mygcc, build your GCC into /opt/mygcc, build your own system libraries into there if you want also.

A major problem with ignoring the default system libraries will be that programs you build against some other library may not run on the system.

Even if you build static binaries you may end up with a binary that won't run on an older OS kernel. For example, pthreads built on a NPTL Linux kernel will not run on a 2.2 or 2.4 kernel.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜