2016-09-26 115 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