Pergunta

I am trying to compile a project for iOS 6 in XCode, and I am using the following headers, which include the functionality I need:

#include "cdjpeg.h"     /* Common decls for cjpeg/djpeg applications */
#include "transupp.h"   /* Support routines for jpegtran */

Those are straight out of jpegtran utility sources. I have installed the jpeg library before, and there is libjpeg.a in my /usr/local/lib/. However when I try to compile, I am getting an error "Undefined symbols for architecture i386" or "Undefined symbols for architecture armv7", depending on whether target is an iPhone simulator or not. Here are the keywords it can't find symbols for:

  "_jpeg_stdio_src"
  "_jpeg_finish_compress"
  "_jcopy_markers_execute"
  "_jpeg_copy_critical_parameters"
  "_jtransform_adjust_parameters"
  "_jpeg_destroy_compress"
  "_jtransform_execute_transform"
  "_jpeg_finish_decompress"
  "_jpeg_read_header"
  "_jtransform_request_workspace"
  "_jpeg_write_coefficients"
  "_jpeg_read_coefficients"
  "_jpeg_destroy_decompress"
  "_jpeg_stdio_dest"
  "_jcopy_markers_setup"

I have encountered the missing symbol errors before, and always ended giving up on using 3rd party libraries, but in that particular case there's no way around.

What am I doing wrong here?

EDIT: I have added libjpeg.a to project settings and it did go further, but stopped now at:

Apple clang version 4.1 (tags/Apple/clang-421.11.66) (based on LLVM 3.1svn)
Target: i386-apple-darwin12.2.0
Thread model: posix
"lots-of-debug-paths"
ld: library not found for -ljpeg
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Foi útil?

Solução

I dunno how you compiled it. But you need to change the make install in order to compile it in i386 and armv7. I'm pretty sure you just run the make, so it compiled it for you mac, which is certainly a x84_64 arch, and this is certainly not what you want

You can check with

lipo -info  /usr/local/lib/libjpeg.a // if libjpeg.a is at this path

or

file /usr/local/lib/libjpeg.a

Outras dicas

I recently needed libjpeg for iOS too (as a dependency of another third party library)

I ended up simply using the libjpeg-turbo, which comes with a precompiled fat binary

Architectures in the fat file: libjpeg.dylib are: i386 x86_64 armv6 armv7 armv7s arm64 
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top