2016-09-26 226 views
1

我一直在尝试创建一个静态链接的vips版本,但一直无法执行。有没有可能创建一个静态链接的vips命令?静态链接vips(libvips)二进制

我编译的平台是Ubuntu 16.04。

make命令我运行:我不是将其配置为使用Python或ImageMagick的,(在配置输出的显示“无”)

make LDFLAGS=-all-static 

。我得到的错误是:

/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 

有我链接到的是导致该问题的特定库?

回答

1

我想是这样的:

$ 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,则会得到一个很长的列表。真正的静态二进制文件不再存在。

为什么你想要一个静态二进制文件?如果为了简化发行,平板电脑和活泼的东西可能会更好。您也可以自行排序 - 例如,vips带有一个简单的包装脚本,可以使共享二进制文件可重定位。

+0

我曾希望将它部署在一个极简主义的Docker容器中,该容器也有静态版本的ffmpeg和ffprobe。我想我只是不确定为什么图像转换程序需要像getservbyname这样的调用,所以希望有一些依赖我可以放弃。 – SjB

+0

vips使用glib来提高可移植性,而且glib有很多东西。你可以尝试用自己的glib去掉一些东西,这可能会有所帮助。我认为静态二进制文件^^^^可以在任何16.04安装中运行,这是一些东西,但它可能不适用于非常小的Linux安装。 OpenWRT有一个libvips包,这是非常小的,也许你可以适应它? – user894763

+0

我认为使用类似dietlibc的东西可能有效,但还没有机会重新访问。 – SjB