title: Compiling/using libjpeg in Windows for Eclipse
body: <p>This question/answer will eventually serve as complete answer for this question: <a href="https://stackoverflow.com/q/14586759/1666510">How can I manipulate/rotate a JPEG image in C++?</a> Since the answers given to that question are only useful if you have already done all of this below.</p>
  
  <p>I followed the guide here: <a href="https://stackoverflow.com/questions/12652178/compiling-libjpeg">Compiling libjpeg</a>
  (The accepted answer guide using MINGW32 Shell)</p>
  
  <p>It doesn't work despite having downloaded a fresh copy:</p>
  
  <pre><code>$ make
  make  all-am
  make[1]: Entering directory `/c/tmp/jpeg-9'
    CC       jaricom.lo
    CC       jcapimin.lo
  jcapimin.c:127:1: error: conflicting types for 'jpeg_suppress_tables'
  jcapimin.c:128:1: note: an argument type that has a default promotion can't matc
  h an empty parameter name list declaration
  In file included from jcapimin.c:22:0:
  jpeglib.h:997:14: note: previous declaration of 'jpeg_suppress_tables' was here
  make[1]: *** [jcapimin.lo] Error 1
  make[1]: Leaving directory `/c/tmp/jpeg-9'
  make: *** [all] Error 2
  </code></pre>
  
  <p>8d and 9 both do the same.</p>
  
  <p>After making the change noted in this question: <a href="https://stackoverflow.com/questions/13087749/compile-libjpeg-with-mingw">Compile libjpeg with mingw</a></p>
  
  <blockquote>
    <p>Add the following definition to the jconfig.h</p>
    
    <p><code>#define HAVE_PROTOTYPES 1</code></p>
  </blockquote>
  
  <p>I get this output when making:</p>
  
  <pre><code>$ make
  make  all-am
  make[1]: Entering directory `/c/tmp/jpeg-9'
    CC       jaricom.lo
  In file included from jinclude.h:20:0,
                   from jaricom.c:17:
  jconfig.h:5:24: warning: extra tokens at end of #undef directive [enabled by def
  ault]
    CC       jcapimin.lo
  In file included from jinclude.h:20:0,
                   from jcapimin.c:21:
  jconfig.h:5:24: warning: extra tokens at end of #undef directive [enabled by def
  ault]
  jcapimin.c:127:1: error: conflicting types for 'jpeg_suppress_tables'
  jcapimin.c:128:1: note: an argument type that has a default promotion can't matc
  h an empty parameter name list declaration
  In file included from jcapimin.c:22:0:
  jpeglib.h:997:14: note: previous declaration of 'jpeg_suppress_tables' was here
  make[1]: *** [jcapimin.lo] Error 1
  make[1]: Leaving directory `/c/tmp/jpeg-9'
  make: *** [all] Error 2
  </code></pre>
  
  <p>Then you have to run "autoheader" to fix this and make again.</p>
  
  <p>It supposedly made but there is nothing in my build directory set by ./configure --prefix=/c/tmp/jpeg-9-build/</p>
  
  <p>I found the libjpeg-9.dll in the .lib folder within the project directory.</p>
  
  <p>Messy..Now the question is: How do I use it in Eclipse?</p>
  
  <p>I have the exe's in the main directory, some exe's and the DLL in the .lib sub-directory but no .lib file - How do I go about importing these into an eclipse project so that I can call functions in the DLL?</p>
  
  <p><code>$ make install</code> gathered the files in the build directory.</p>
  
  <p>I migrated the contents of the build directory into the working Eclipse project and linked the library and include paths:</p>
  
  <p><img src="https://i.stack.imgur.com/hwRtn.png" alt="Directory tree for basic implementation of jpeglib in Eclipse"></p>
  
  <p>I'm not sure if this is right for how I want to use it but it's something and it compiles. Next part: Calling functions out of the DLL?</p>
  
  <p>Related to using compiled jpegtran.exe: <a href="https://stackoverflow.com/q/14612809/1666510">jpegtran.exe not correctly rotating image</a></p>
  
  <p>Trying to use libraries and compile in separate project: <a href="https://stackoverflow.com/q/14631530/1666510">Need help compiling jpegtran.c code from libjpeg</a></p>
  
  <p>Current issue: <a href="https://stackoverflow.com/q/14631530/1666510">Need help compiling jpegtran.c code from libjpeg</a></p>