我正在尝试在 Ubuntu 16.04 LTS 上安装Sharp。
我本来没有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 --cflags 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 是全新安装(截至昨天),以防万一。