我已经包含了标题netdb.h,包含在哪里getaddrinfo,但是gcc发出了这个警告:
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
Run Code Online (Sandbox Code Playgroud)
如何静态编译丢失的文件?
可能的解决方案:
可能是glibc安装缺少静态编译所需的相应目标文件.如果是这种情况,请创建相应的目标文件并在编译时链接它.
尝试EGLIBC而不是glibc.
我成功地用dietlibc编译了我的程序,它编译时没有任何错误加上得到的二进制文件比glibc制作的要小得多.
我对开源和许可证有基本的了解问题.有人可以为下面的场景澄清一些问题.对不起,如果它是非常基本的
我正在编写一个专有软件,我计划使用一些开源库.我还需要glibc和C编译器,但不想使用我操作系统中的默认gcc工具链,所以使用crosstools-ng构建我自己的
现在在ct-ng中,我想libstdc ++库是静态链接的(这对于c ++而言我不会在大多数情况下使用它我猜)但是从我的工具链配置是我的libc静态或动态链接?如果是这种情况,鉴于glibc是LGPL,并且我可以将其链接到我的专有软件,这种静态链接是否会导致任何问题给我许可?我的软件仍然可以近距离获取吗?或者我必须释放编译的对象.
我的工具链配置如下,如果glibc静态或动态链接,有人可以指向我吗?
Target: x86_64-some-linux-gnu
Configured with: /home/balravin/tools/platform/x86/src/gnu/gcc/4.4.7/.build/src/gcc-4.4.7/configure --build=i686-build_pc-linux-gnu --host=i686-build_pc-linux-gnu --target=x86_64-some-linux-gnu --prefix=/home/balravin/tools/platform/x86/obj/gnu/gcc/4.4.7/x86_64-some-linux-gnu --with-sysroot=/home/balravin/tools/platform/x86/obj/gnu/gcc/4.4.7/x86_64-some-linux-gnu/x86_64-some-linux-gnu/sysroot --enable-languages=c,c++,fortran --with-pkgversion='crosstool-NG 1.15.3' --disable-sjlj-exceptions --enable-__cxa_atexit --enable-libmudflap --enable-libgomp --enable-libssp --with-gmp=/home/balravin/tools/platform/x86/src/gnu/gcc/4.4.7/.build/x86_64-some-linux-gnu/buildtools --with-mpfr=/home/balravin/tools/platform/x86/src/gnu/gcc/4.4.7/.build/x86_64-some-linux-gnu/buildtools --with-ppl=/home/balravin/tools/platform/x86/src/gnu/gcc/4.4.7/.build/x86_64-some-linux-gnu/buildtools --with-cloog=/home/balravin/tools/platform/x86/src/gnu/gcc/4.4.7/.build/x86_64-some-linux-gnu/buildtools --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --enable-threads=posix --enable-target-optspace --with-long-double-128 --disable-multilib --with-local-prefix=/home/balravin/tools/platform/x86/obj/gnu/gcc/4.4.7/x86_64-some-linux-gnu/x86_64-some-linux-gnu/sysroot --enable-c99 --enable-long-long
Thread model: posix
gcc version 4.4.7 (crosstool-NG 1.15.3)
Run Code Online (Sandbox Code Playgroud)