创建静态链接使用的getaddrinfo二进制? [英] Create statically-linked binary that uses getaddrinfo?

查看:1448
本文介绍了创建静态链接使用的getaddrinfo二进制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经包括了头netdb.h中,其中包含的getaddrinfo,但GCC的问题这样的警告:

 警告:在静态链接的应用程序中使用的getaddrinfo'需要在运行时从glibc的版本用于连接的共享库GCC -m32 -static -s -O2 -std = C99 -D_POSIX_C_SOURCE = 200112L myprogram.c

如何才能静态编译缺少什么文件?

可能的解决方案:


  1. 这可能是因为glibc的安装缺少必要的静态编译相应的目标文件。如果是这样的情况下,创建相应的目标文件,并在编译链接。


  2. 尝试EGLIBC,而不是glibc的。


  3. 我成功地编译我的程序与dietlibc其中没有任何错误编译加上生成的二进制比什么glibc的让小的多。



解决方案

glibc的使用中的libnss支持多个地址解析服务的不同供应商。不幸的是,你不能静态链接中的libnss,因为正是提供商它加载取决于本地系统的配置。

I have included the header netdb.h, where getaddrinfo is included, but gcc issues this warning:

warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking

gcc -m32 -static -s -O2 -std=c99 -D_POSIX_C_SOURCE=200112L myprogram.c

How can I statically compile whatever file is missing ?

Possible solutions:

  1. It could be that the glibc installation is missing the corresponding object file necessary for static compilation. If that is the case, create the corresponding object file and link it at compilation.

  2. Try EGLIBC instead of glibc.

  3. I succesfully compiled my program with dietlibc which compiled without any errors plus the resulting binary was much smaller than what glibc makes.

解决方案

glibc uses libnss to support a number of different providers for address resolution services. Unfortunately, you cannot statically link libnss, as exactly what providers it loads depends on the local system's configuration.

这篇关于创建静态链接使用的getaddrinfo二进制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆