Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install Problem: 'jpeglib.h' file not found #348

Closed
georgecoltart opened this issue Oct 26, 2013 · 27 comments
Closed

Install Problem: 'jpeglib.h' file not found #348

georgecoltart opened this issue Oct 26, 2013 · 27 comments

Comments

@georgecoltart
Copy link

I've been going round the bend trying to solve this.
When I attempt to install I get:

npm install canvas
npm http GET https://registry.npmjs.org/canvas
npm http 304 https://registry.npmjs.org/canvas
npm http GET https://registry.npmjs.org/nan
npm http 304 https://registry.npmjs.org/nan

> canvas@1.1.1 install /Users/georgecoltart/Sites/tilestitch/node_modules/canvas
> node-gyp rebuild

  CXX(target) Release/obj.target/canvas/src/Canvas.o
In file included from ../src/Canvas.cc:19:
../src/JPEGStream.h:11:10: fatal error: 'jpeglib.h' file not found
#include <jpeglib.h>
         ^
1 error generated.
make: *** [Release/obj.target/canvas/src/Canvas.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:789:12)
gyp ERR! System Darwin 13.0.0
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/georgecoltart/Sites/tilestitch/node_modules/canvas
gyp ERR! node -v v0.10.21
gyp ERR! node-gyp -v v0.10.10
gyp ERR! not ok 
npm ERR! weird error 1
npm ERR! not ok code 0

Having done a search, the jpeglib.h file is in /usr/include/jpeglib.h
I'm pretty sure I installed it correctly, but it must be a broken reference.

Can someone tell me where this jpeg lib is expected to be located for the canvas install to find it?

Thanks a lot.

@mojodna
Copy link
Contributor

mojodna commented Oct 26, 2013

jpeglib.h is in /usr/local/include on my system, having been installed via brew install jpeg. How did you install it?

@georgecoltart
Copy link
Author

Yes it was installed via brew, and it does exist at that location: /usr/local/include
Should the npm install be looking there?
Im on 10.9 which might not be helping things...

@mojodna
Copy link
Contributor

mojodna commented Oct 26, 2013

I just upgraded from 10.7 to 10.9, so I'm trying to reproduce.

npm install cairo didn't work out of the box (where it previously did), even with PKG_CONFIG set. So far, I've done the following:

brew uninstall cairo
brew install cairo
# fails, tells me to link pixman
brew link pixman
brew install cairo
# fails, tells me to install XQuartz
# install XQuartz
brew install cairo
# fails, tells me to install Xcode Command Line Tools
xcode-select --install
brew install cairo
# installs glib, cairo
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/opt/X11/lib/pkgconfig npm install canvas
# installs node-canvas successfully

I didn't do anything with jpeg here, but you might have better luck brew uninstall jpeg && brew install jpeg first...

@georgecoltart
Copy link
Author

Fixed!
I seemed to have missed any warning about Xcode Command Tools, and was certain that Cairo had successfully installed where maybe it hadnt. I'd reinstalled it a number of times without any warnings.

O well thanks a lot!

@isnolan
Copy link

isnolan commented Nov 11, 2013

I also encountered this problem, no solution

@georgecoltart
Copy link
Author

If you are on Mavericks, you'll need to install the Xcode command line tools, even if you did it on mountain lion.
See top answer here: http://stackoverflow.com/questions/9329243/xcode-4-4-and-later-install-command-line-tools

The errors I was getting didnt mention anything about this, however it was this that fixed the issue, so I would double check you have this installed correctly.

@isnolan
Copy link

isnolan commented Nov 11, 2013

I'm on Mavericks. Thanks a lot , I have solved.

brew update
brew doctor
xcode-select --install
brew install cairo gobject-introspection pixman

@ajatolah
Copy link

ajatolah commented Mar 5, 2014

I had the same problem, yhostc's solution solved it, thank you

@davidrinnan
Copy link

I had the same problem. Found this post. Wrote 'xcode-select --install'
in terminal and installed xcode command line tools via the prompt
retried npm install canvas and it worked directly without issues and without reinstalling cairo via homebrew. so many thanks @georgecoltart

@soyuka
Copy link

soyuka commented Aug 29, 2014

Thanks @yhostc! xcode-select --install did the trick. I think this comes from my recent migration to Mavericks.

My steps were:

brew install cairo
brew link cairo
#see brew issue below
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/opt/X11/lib/pkgconfig
xcode-select --install
npm i canvas

see #14123 for the pkgconfig

This should definitely be added to the wiki.

@nodecode
Copy link

I had the same problem, and I have long searched on the internet, but nothing has solved the problem. But now with brew uninstall jpeg && brew install jpeg it finally worked. jpeg was indeed installed before, but apparently there was a mistake. Thanks @mojodna

$ brew uninstall jpeg && brew install jpeg
Uninstalling /usr/local/Cellar/jpeg/8d...
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/jpeg-8d.mavericks.bottle.2.tar.gz
######################################################################## 100,0%
==> Pouring jpeg-8d.mavericks.bottle.2.tar.gz
🍺  /usr/local/Cellar/jpeg/8d: 18 files, 780K

@piranna
Copy link
Contributor

piranna commented Sep 30, 2014

I'm having the same problem, but in this case in Ubuntu 14.10, not on OSX... :-(

@PaulMougel
Copy link

Here's how I fixed it:

  1. Install X11
  2. Run
$ xcode-select --install
$ export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/opt/X11/lib/pkgconfig
$ npm install

@dosapati
Copy link

Had the same issue, yhostc's solution solved it, thank you

@yaserabdelaziz
Copy link

No one of these solutions helped in my case, but this helped fix it :
https://gist.github.com/darul75/9125097

@piranna
Copy link
Contributor

piranna commented Aug 9, 2015

I think node-canvas should download the dependencies and compile them statically to prevent this problems...

@Drjacky
Copy link

Drjacky commented Oct 18, 2015

What about in ubuntu?!

@piranna
Copy link
Contributor

piranna commented Oct 18, 2015

My fork download all dependencies and compike them statically inside the canvas.node binary, so these problems are not happening anymore. I did a pull-request sometime ago.

@dbkaplun
Copy link

+1

@lizhanhui
Copy link

For Ubuntu users, please install the package: libjpeg-dev
It works for Wily(15.04 64bit).

@0326
Copy link

0326 commented Jan 21, 2016

$ xcode-select --install works for mac!

@tomerb15
Copy link

I did a lot of the things writen here for my mac OSX but non seam to work.

Finally i uninstalled node-canvas from my node_modules library and reinstall it and now i can work with jpegs!

I feel like i have won a gold medal at the Olympics

@whxaxes
Copy link

whxaxes commented Feb 1, 2016

great !!!!!!!!! xcode-select --install works

thanks a lot

@LinusU
Copy link
Collaborator

LinusU commented Feb 15, 2016

Please try xcode-select --install :)

@LinusU LinusU closed this as completed Feb 15, 2016
@piranna
Copy link
Contributor

piranna commented Feb 15, 2016

As I said before, by compiling statically this problem gets fixed. My pull-request is waiting...

@zhaotai
Copy link

zhaotai commented May 10, 2016

My solution is the same with @LinusU.
Just xcode-select --install.

@javadba
Copy link

javadba commented Apr 23, 2017

xcode-select --install works for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests