Compiling/using libjpeg in Windows for Eclipse

▼魔方 西西 提交于 2019-12-20 06:43:17

问题


This question/answer will eventually serve as complete answer for this question: How can I manipulate/rotate a JPEG image in C++? Since the answers given to that question are only useful if you have already done all of this below.

I followed the guide here: Compiling libjpeg (The accepted answer guide using MINGW32 Shell)

It doesn't work despite having downloaded a fresh copy:

$ 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

8d and 9 both do the same.

After making the change noted in this question: Compile libjpeg with mingw

Add the following definition to the jconfig.h

#define HAVE_PROTOTYPES 1

I get this output when making:

$ 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

Then you have to run "autoheader" to fix this and make again.

It supposedly made but there is nothing in my build directory set by ./configure --prefix=/c/tmp/jpeg-9-build/

I found the libjpeg-9.dll in the .lib folder within the project directory.

Messy..Now the question is: How do I use it in Eclipse?

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?

$ make install gathered the files in the build directory.

I migrated the contents of the build directory into the working Eclipse project and linked the library and include paths:

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?

Related to using compiled jpegtran.exe: jpegtran.exe not correctly rotating image

Trying to use libraries and compile in separate project: Need help compiling jpegtran.c code from libjpeg

Current issue: Need help compiling jpegtran.c code from libjpeg


回答1:


Your advice for updating the jconfig.h file to #define HAVE_PROTOTYPES 1 is only a band-aid solution for a deeper problem: jconfig.h is corrupted and has incorrect #undef for many important items your compiler supports.

The proper way to work around this is to follow the install.txt advice to manually compile ckconfig.c and have it generate a jconfig.h for you, then proceed to make, and make install.



来源:https://stackoverflow.com/questions/14593579/compiling-using-libjpeg-in-windows-for-eclipse

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!