我正在尝试用 C++ 读取 jpg 图像。我按照此链接 libjpg 中的建议下载了 https://www.opengl.org/wiki/Image_Libraries 并安装了它。虽然当我包含库时 Xcode 构建失败,说找不到“jpeglib.h”文件

#include <jpeglib.h>

我可以在/usr/local/include/目录中看到标题,所以我不明白为什么 Xcode 看不到它。

操作系统和软件详细信息:

OSX 10.11 (El Capitan)

Xcode 7.0.1

编辑:
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

最佳答案

好的,看起来您只需要:

  • /usr/local/include 添加到标题搜索路径(关闭递归 )。 This 看起来仍然相关。
  • 与库 (reference) 的链接二进制文件中的 /usr/local/lib/libjpeg.a 显式链接。这将链接到静态库中,这意味着无需将 JPEG 动态库与您的应用程序一起分发。
  • 关于c++ - 找不到“jpeglib.h”文件,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33168293/

    10-12 21:01