为 MATLAB 编译 jpeg_read.c 作为 mexmaci64

Compile jpeg_read.c as mexmaci64 for MATLAB

我从 this site, then downloaded the JPEG compiler tools from here 下载了适用于 MATLAB 的 jpeg_toolbox。我按照说明为 Mac (UNIX*) 配置整体。

现在,我需要为 MATLAB 编译第一个 link 中包含的 jpeg_read.cjpeg_write.c,因为工具箱不提供 mexmaci64 文件。然而,当我尝试:

mex jpeg_read.c

MATLAB returns出现如下错误:

Error using mex
Undefined symbols for architecture x86_64:
  "_jpeg_CreateDecompress", referenced from:
      _mexFunction in jpeg_read.o
  "_jpeg_destroy_decompress", referenced from:
      _mexFunction in jpeg_read.o
  "_jpeg_finish_decompress", referenced from:
      _mexFunction in jpeg_read.o
  "_jpeg_read_coefficients", referenced from:
      _mexFunction in jpeg_read.o
  "_jpeg_read_header", referenced from:
      _mexFunction in jpeg_read.o
  "_jpeg_save_markers", referenced from:
      _mexFunction in jpeg_read.o
  "_jpeg_std_error", referenced from:
      _mexFunction in jpeg_read.o
  "_jpeg_stdio_src", referenced from:
      _mexFunction in jpeg_read.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

如何编译程序?否则,你们中有人已经得到我需要的 mexmaci64 了吗?

我是这样解决的:

brew install libjpeg

我在 /usr/local/lib 中找到了库,所以在 MATLAB 上,我移动到包含必须编译的 .c 文件的文件夹中,我 运行:

mex jpeg_read.c "/usr/local/lib/libjpeg.a"
mex jpeg_write.c "/usr/local/lib/libjpeg.a"