2
votes

I downloaded the jpeg_toolbox for MATLAB from this site, then downloaded the JPEG compiler tools from here. I followed the instruction to configure the whole for Mac (UNIX*).

Now, I would need to compile the jpeg_read.c and jpeg_write.c contained into the first link for MATLAB, because the toolbox does not provide the mexmaci64 files. However when I try to:

mex jpeg_read.c

MATLAB returns the following error:

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)

How can I compile the program? Otherwise, does any of you have already got the mexmaci64 I would need?

1
You'll need to link against the library also. As the instructions tell you: mex -I<IJGPATH> jpeg_read.c <LIBJPEG>. - Cris Luengo
Yes, and there are supposed to be some libraries called libjpeg.a/libjpeg.lib, but I can only find extensions that the mex compiler does not recognise. - Lorenzo
The instructions also say "build the libjpeg library using the make files and instructions contained in the IJG JPEG distribution." If you did that, you'll have a file called libjpeg.a or libjpeg.dylib. Add that file, including the full path, to the mex command as directed. - Cris Luengo
I did it, actually, but the only libjpeg files have extension .la .map .pc .pc.in. However, if I try to use mex with one of those, the compiler complains it does not recognise nor of those. - Lorenzo
And there are no files at all with a .a or .dylib extension? - Cris Luengo

1 Answers

1
votes

I solved this way:

brew install libjpeg

I found the libraries in /usr/local/lib so on MATLAB I moved into the folder that contained the .c files that had to be compiled and I ran:

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