static-libraries - 静态链接的 vips (libvips) 二进制文件

标签 static-libraries vips

我一直在尝试创建一个静态链接的 vips 版本,但一直无法做到。是否可以创建静态链接的 vips 命令?

我正在编译的平台是 Ubuntu 16.04。

我正在运行的 make 命令:

 make LDFLAGS=-all-static

我没有将它配置为使用 python 或 imagemagick,(那些在配置输出中显示“否”)。我得到的错误是:
/usr/bin/ld: cannot find -lgdk_pixbuf-2.0
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libgio-2.0.a(libgio_2_0_la-glocalfileinfo.o): In function `lookup_gid_name':
(.text+0x11d7): warning: Using 'getgrgid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libgio-2.0.a(libgio_2_0_la-glocalvfs.o): In function `g_local_vfs_parse_name':
(.text+0x1cd): warning: Using 'getpwnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libglib-2.0.a(libglib_2_0_la-gutils.o): In function `g_get_user_database_entry':
(.text+0x249): warning: Using 'getpwuid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libglib-2.0.a(libglib_2_0_la-gutils.o): In function `g_get_user_database_entry':
(.text+0xcf): warning: Using 'getpwnam_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libgio-2.0.a(libgio_2_0_la-glocalfileinfo.o): In function `lookup_uid_data':
(.text+0x1054): warning: Using 'getpwuid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libxml2.a(nanohttp.o): In function `xmlNanoHTTPConnectHost':
(.text+0x924): warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libxml2.a(nanohttp.o): In function `xmlNanoHTTPConnectHost':
(.text+0x9f4): warning: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libgio-2.0.a(libgio_2_0_la-gnetworkaddress.o): In function `g_network_address_parse':
(.text+0xc39): warning: Using 'getservbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libgio-2.0.a(libgio_2_0_la-gnetworkaddress.o): In function `g_network_address_parse':
(.text+0xc4e): warning: Using 'endservent' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
collect2: error: ld returned 1 exit status
Makefile:597: recipe for target 'vips' failed
make[2]: *** [vips] Error 1
make[2]: Leaving directory '/usr/local/src/vips-8.4.1/tools'
Makefile:631: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/usr/local/src/vips-8.4.1'
Makefile:536: recipe for target 'all' failed
make: *** [all] Error 2

从我发现的,例如这里:
Create statically-linked binary that uses getaddrinfo?
是因为这是 libnss 的问题。但是在 ./configure --help 输出中没有 --enable-static-flag。即便如此,我也尝试过,但并没有解决我的问题。

我正在链接的库(根据配置输出,我已经截断了它):
build radiance support:         yes
build analyze support:          yes
build PPM support:          yes
use fftw3 for FFT:          yes
accelerate loops with orc:      yes
ICC profile support with lcms:      yes (lcms2)
SVG import with librsvg-2.0:        yes
zlib:                   yes
file import/export with libwebp:    yes
file import/export with libpng:     yes (pkg-config libpng >= 1.2.9)
file import/export with libtiff:    yes (pkg-config libtiff-4)
file import/export with giflib:     yes (found by search)
file import/export with libjpeg:    yes
use libexif to load/save JPEG metadata: yes

是否有我正在链接的特定库导致了问题?

最佳答案

我试过这样:

$ CFLAGS="-static" CXXFLAGS="-static" ./configure --prefix=/home/john/vips --without-python --without-magick

它似乎有效:
$ ls ~/vips/lib
girepository-1.0  libvipsCC.a   libvips-cpp.a   libvips.la  python2.7
libvips.a         libvipsCC.la  libvips-cpp.la  pkgconfig
$ which vips
/home/john/vips/bin/vips
$ ls -l ~/vips/bin/vips
-rwxr-xr-x 1 john john 6373864 Sep 27 13:16 /home/john/vips/bin/vips
$ vips invert /data/john/pics/k2.jpg x.jpg
$ eog x.jpg

不过,我并没有对其进行太多测试,而且我怀疑它不是很静态。如果你在 vips 上运行 ldd二进制,例如,你会得到一个很长的列表。真正的静态二进制文件不再存在。

为什么需要静态二进制文件?如果是为了简化分发,像 flatpack 和 snappy 这样的东西可能会更好。您也可以自己制作——例如,vips 带有一个简单的包装脚本,可以使共享二进制文件可重定位。

关于static-libraries - 静态链接的 vips (libvips) 二进制文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39713986/

相关文章:

c++ - 错误 LNK2005 : "void __cdecl operator delete(void *)" (? ?3@YAXPAX@Z) 已在 LIBCMTD.lib(delete_scalar.obj) 中定义

c++ - CMake 链接 Windows SDK

c++ - 这些链接器错误的含义是什么?

java - Android NDK 使用静态库 -> 函数尚未声明

ios - Xcode 子项目框架依赖构建失败

linux - 找不到配置文件

c - 如何使用 VIPS 添加文本中字符之间的间距?

ubuntu - 安装 Sharp/usr/include/vips/vips8 :35:25: fatal error: glib-object. h