问题
I am trying to read a jpg image in c++. I downloaded libjpg as it was suggested at this link https://www.opengl.org/wiki/Image_Libraries and installed it. Although when I include the library Xcode fails building saying 'jpeglib.h' file not found
#include <jpeglib.h>
I can see the header in /usr/local/include/ directory so I can't understand why Xcode won't see it.
OS and Software details:
OSX 10.11 (El Capitan)
Xcode 7.0.1
edit:
find /usr/local -name \*jpeg\* -print -name \*jpg\* -print
/usr/local/bin/cjpeg
/usr/local/bin/djpeg
/usr/local/bin/jpegtran
/usr/local/Cellar/jpeg
/usr/local/Cellar/jpeg/8d/bin/cjpeg
/usr/local/Cellar/jpeg/8d/bin/djpeg
/usr/local/Cellar/jpeg/8d/bin/jpegtran
/usr/local/Cellar/jpeg/8d/include/jpeglib.h
/usr/local/Cellar/jpeg/8d/lib/libjpeg.8.dylib
/usr/local/Cellar/jpeg/8d/lib/libjpeg.a
/usr/local/Cellar/jpeg/8d/lib/libjpeg.dylib
/usr/local/Cellar/jpeg/8d/share/man/man1/cjpeg.1
/usr/local/Cellar/jpeg/8d/share/man/man1/djpeg.1
/usr/local/Cellar/jpeg/8d/share/man/man1/jpegtran.1
/usr/local/include/jpeglib.h
/usr/local/lib/libjpeg.8.dylib
/usr/local/lib/libjpeg.a
/usr/local/lib/libjpeg.dylib
/usr/local/Library/Aliases/libjpeg
/usr/local/Library/Aliases/libjpeg-turbo
/usr/local/Library/Formula/jpeg-archive.rb
/usr/local/Library/Formula/jpeg-turbo.rb
/usr/local/Library/Formula/jpeg.rb
/usr/local/Library/Formula/jpeginfo.rb
/usr/local/Library/Formula/jpegoptim.rb
/usr/local/Library/Formula/jpegrescan.rb
/usr/local/Library/Formula/mjpegtools.rb
/usr/local/Library/Formula/mozjpeg.rb
/usr/local/Library/Formula/openjpeg.rb
/usr/local/Library/Formula/recoverjpeg.rb
/usr/local/Library/LinkedKegs/jpeg
/usr/local/opt/jpeg
/usr/local/share/man/man1/cjpeg.1
/usr/local/share/man/man1/djpeg.1
/usr/local/share/man/man1/jpegtran.1
/usr/local/src/jpeg-9a
/usr/local/src/jpeg-9a/.deps/cdjpeg.Po
/usr/local/src/jpeg-9a/.deps/cjpeg.Po
/usr/local/src/jpeg-9a/.deps/djpeg.Po
/usr/local/src/jpeg-9a/.deps/jpegtran.Po
/usr/local/src/jpeg-9a/.libs/cjpeg
/usr/local/src/jpeg-9a/.libs/djpeg
/usr/local/src/jpeg-9a/.libs/jpegtran
/usr/local/src/jpeg-9a/.libs/libjpeg.9.dylib
/usr/local/src/jpeg-9a/.libs/libjpeg.a
/usr/local/src/jpeg-9a/.libs/libjpeg.dylib
/usr/local/src/jpeg-9a/.libs/libjpeg.la
/usr/local/src/jpeg-9a/.libs/libjpeg.lai
/usr/local/src/jpeg-9a/cdjpeg.c
/usr/local/src/jpeg-9a/cdjpeg.h
/usr/local/src/jpeg-9a/cdjpeg.o
/usr/local/src/jpeg-9a/cjpeg
/usr/local/src/jpeg-9a/cjpeg.1
/usr/local/src/jpeg-9a/cjpeg.c
/usr/local/src/jpeg-9a/cjpeg.o
/usr/local/src/jpeg-9a/djpeg
/usr/local/src/jpeg-9a/djpeg.1
/usr/local/src/jpeg-9a/djpeg.c
/usr/local/src/jpeg-9a/djpeg.o
/usr/local/src/jpeg-9a/jpegint.h
/usr/local/src/jpeg-9a/jpeglib.h
/usr/local/src/jpeg-9a/jpegtran
/usr/local/src/jpeg-9a/jpegtran.1
/usr/local/src/jpeg-9a/jpegtran.c
/usr/local/src/jpeg-9a/jpegtran.o
/usr/local/src/jpeg-9a/libjpeg.la
/usr/local/src/jpeg-9a/libjpeg.map
/usr/local/src/jpeg-9a/libjpeg.txt
/usr/local/src/jpeg-9a/makcjpeg.st
/usr/local/src/jpeg-9a/makdjpeg.st
/usr/local/src/jpeg-9a/makljpeg.st
/usr/local/src/jpeg-9a/maktjpeg.st
/usr/local/src/jpegsrc.v9a.tar.gz
回答1:
OK, it looks like you just need to:
- Add
/usr/local/include
to the Header Search Path (turn recursive off). This still looks relevant. - Link explicitly against
/usr/local/lib/libjpeg.a
from within Link binary with libraries (reference). This will link in the static library, meaning there is no need to distribute the JPEG dynamic library with your app.
来源:https://stackoverflow.com/questions/33168293/jpeglib-h-file-not-found