事实上,Linux上的-staticGCC标志现在不起作用.让我引用GNU libc常见问题:
2.22. Even statically linked programs need some shared libraries which is not acceptable for me. What can I do?
{AJ}NSS(有关详细信息,请键入'info'
解决方案是使用
gcc -static test-netdb.c -o test-netdb \ -Wl,--start-group -lc -lnss_files -lnss_dns -lresolv -Wl,--end-group
The problem with this approach is that you've got to link every static program that uses NSS routines with all those libraries.
{UD} In fact, one cannot say anymore that a libc compiled with this option is using NSS. There is no switch anymore. Therefore it is highly recommended not to use --enable-static-nss since this makes the behaviour of the programs on the system inconsistent.
考虑到这个事实,现在有没有合理的方法在Linux上创建一个完整的静态构建,或者静态链接在Linux上完全失效?我指的是静态构建:
- 行为方式与
- 研究glibc环境和Linux版本的合理变化;