我正在尝试在Ubuntu 16.04 LTS上安装夏普。
我最初没有vips,所以我安装了
sudo apt-get install libvips-dev这修复了第一个错误,但现在我得到了另一个错误,我被困住了:
In file included from ../src/common.cc:25:0:
/usr/include/vips/vips8:35:25: fatal error: glib-object.h: No such file or directory
compilation terminated.
sharp.target.mk:115: recipe for target 'Release/obj.target/sharp/src/common.o' failed
make: *** [Release/obj.target/sharp/src/common.o] Error 1
make: Leaving directory '/home/rachel/node_modules/sharp/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/share/node-gyp/lib/build.js:269:23)
gyp ERR! stack at emitTwo (events.js:87:13)
gyp ERR! stack at ChildProcess.emit (events.js:172:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Linux 4.15.0-36-generic
gyp ERR! command "/usr/bin/nodejs" "/usr/bin/node-gyp" "rebuild"
gyp ERR! cwd /home/rachel/node_modules/sharp
gyp ERR! node -v v4.2.6
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok所以,我找出了glib-object.h属于哪个包,并试图安装它,但它已经安装了。事实上,这个文件确实存在。
/usr/include/glib-2.0/glib-object.h在大量浏览之后,我发现了一个类似的问题,他们问标题的位置是否在pkg-config --cflag vips-cpp中。对于提问者来说,它不是,这导致了修复,但对我来说,它是(倒数第二)。
> pkg-config --cflags vips-cpp
-pthread -fopenmp -DMAGICKCORE_HDRI_ENABLE=0
-DMAGICKCORE_QUANTUM_DEPTH=16
-fopenmp -DMAGICKCORE_HDRI_ENABLE=0
-DMAGICKCORE_QUANTUM_DEPTH=16 -I/usr/include/libgsf-1
-I/usr/include/libxml2
-I/usr/include/x86_64-linux-gnu//ImageMagick-6
-I/usr/include/ImageMagick-6
-I/usr/include/x86_64-linux-gnu//ImageMagick-6
-I/usr/include/ImageMagick-6
-I/usr/include/orc-0.4
-I/usr/include/OpenEXR
-I/usr/include/openslide
-I/usr/lib/x86_64-linux-gnu/hdf5/serial/include
-I/usr/include/pango-1.0
-I/usr/include/harfbuzz
-I/usr/include/pango-1.0
-I/usr/include/freetype2
-I/usr/include/x86_64-linux-gnu
-I/usr/include/libpng12
-I/usr/include/libexif
-I/usr/include/glib-2.0
-I/usr/lib/x86_64-linux-gnu/glib-2.0/include在验证该文件是否存在以及其文件夹是否包含在上述输出中后,我没有找到任何解决方案。我完全不知道下一步该做什么,所以任何建议都会非常感谢。
npm是一个全新的安装(从昨天开始),如果这很重要的话。
发布于 2018-10-29 22:43:32
你有两个问题(我认为):首先,Ubuntu16.04附带的nodejs是4.x,这在2018年4月就不受支持了--当前支持的nodejs是8.x。其次,Ubuntu16.04附带的libvips也很旧,不能很好地与当前的sharp一起工作。
幸运的是,修复方法很简单:使用nodejs 6、8和10,sharp将自动为您下载libvips二进制文件。
我使用此指南安装nodejs 8:
然后只需:
npm install sharp一切都正常了。这里是一个Dockerfile,供参考:
https://github.com/jcupitt/docker-builds/blob/master/sharp-ubuntu16.04/Dockerfile
发布于 2018-10-28 10:36:56
看起来vips-cpp正在寻找GObject,而不是GLib,但是pkg-config文件只要求GLib。GObject是基于GLib的,它们是紧密相关的,但它们不是同一个项目。
您应该以某种方式将gobject-2.0添加到pkg-config依赖项中。您可以在sharp构建系统中做到这一点(无论它位于vips-cpp包中的哪个位置,都要依赖于gobject-2.0)。您还可以修复您的vips-cpp pkg-config文件,以添加gobject-2.0作为依赖项;where the file is depends on your architecture,但它是$LIBDIR/pkg-config/vips-cpp.pc。
发布于 2021-08-11 15:47:50
我也有同样的问题。对我来说,我通过从官方github编译libvips解决了这个问题。以下是说明:https://libvips.github.io/libvips/install.html
git clone git://github.com/jcupitt/libvips.git
cd libvips/
# install dependencies if you have errors during autogen.sh
#sudo apt install gtk-doc-tools
#sudo apt install gobject-introspection
./autogen.sh
make
sudo make install解决glib-object.h问题后,您可能会遇到另一个错误: libvips-cpp.so.42:无法打开共享对象文件:没有这样的文件或目录
这可以通过以下单个命令来解决:
sudo sh -c 'echo "/usr/local/lib" >> /etc/ld.so.conf.d/usrlocal.conf'https://stackoverflow.com/questions/53022392
复制相似问题