DentonW / DevIL

Developer's Image Library (DevIL) is a cross-platform image library utilizing a simple syntax to load, save, convert, manipulate, filter, and display a variety of images with ease. It is highly portable and has been ported to several platforms.
http://openil.sourceforge.net/
GNU Lesser General Public License v2.1
446 stars 138 forks source link

Fix compilation with jasper 3.0.x #102

Open satmandu opened 1 year ago

satmandu commented 1 year ago

Fixes #99 #101 when building against ToT.

Fix from https://aur.archlinux.org/packages/devil-ilut-vanilla#comment-877644

kloczek commented 1 year ago

Tested and it builds correctly with this PR. It would be good to merge this PR.

satmandu commented 1 year ago

I would note that this doesn't build on i686 or armv7l...

satmandu commented 1 year ago

Build with this patch on armv7l:

[30/115] Building CXX object src-IL/CMakeFiles/IL.dir/src/il_jp2.cpp.o
FAILED: src-IL/CMakeFiles/IL.dir/src/il_jp2.cpp.o 
/usr/local/bin/c++ -DIL_EXPORTS -I/usr/local/tmp/crew/devil.20221005092208.dir/DevIL/src-IL/include -I/usr/local/tmp/crew/devil.20221005092208.dir/DevIL/src-IL/../include -O2 -pipe -ffat-lto-objects -fPIC -fuse-ld=mold  -flto -O3 -DNDEBUG -fPIC -std=c++11 -MD -MT src-IL/CMakeFiles/IL.dir/src/il_jp2.cpp.o -MF src-IL/CMakeFiles/IL.dir/src/il_jp2.cpp.o.d -o src-IL/CMakeFiles/IL.dir/src/il_jp2.cpp.o -c /usr/local/tmp/crew/devil.20221005092208.dir/DevIL/src-IL/src/il_jp2.cpp
In file included from /usr/local/include/jasper/jasper.h:73,
                 from /usr/local/tmp/crew/devil.20221005092208.dir/DevIL/src-IL/src/il_jp2.cpp:16:
/usr/local/include/jasper/jas_config.h:115:2: warning: #warning "Your code is being built against an older version of the C standard than JasPer was.  Although this is supported, this may require some extra preprocessor defines when building." [-Wcpp]
  115 | #warning "Your code is being built against an older version of the C standard than JasPer was.  Although this is supported, this may require some extra preprocessor defines when building."
      |  ^~~~~~~
/usr/local/tmp/crew/devil.20221005092208.dir/DevIL/src-IL/src/il_jp2.cpp:380:9: error: invalid conversion from ‘long int (*)(jas_stream_obj_t*, char*, long unsigned int)’ {aka ‘long int (*)(void*, char*, long unsigned int)’} to ‘ssize_t (*)(jas_stream_obj_t*, char*, size_t)’ {aka ‘int (*)(void*, char*, unsigned int)’} [-fpermissive]
  380 |         iJp2_file_read,
      |         ^~~~~~~~~~~~~~
      |         |
      |         long int (*)(jas_stream_obj_t*, char*, long unsigned int) {aka long int (*)(void*, char*, long unsigned int)}
/usr/local/tmp/crew/devil.20221005092208.dir/DevIL/src-IL/src/il_jp2.cpp:381:9: error: invalid conversion from ‘long int (*)(jas_stream_obj_t*, const char*, long unsigned int)’ {aka ‘long int (*)(void*, const char*, long unsigned int)’} to ‘ssize_t (*)(jas_stream_obj_t*, const char*, size_t)’ {aka ‘int (*)(void*, const char*, unsigned int)’} [-fpermissive]
  381 |         iJp2_file_write,
      |         ^~~~~~~~~~~~~~~
      |         |
      |         long int (*)(jas_stream_obj_t*, const char*, long unsigned int) {aka long int (*)(void*, const char*, long unsigned int)}
[31/115] Building CXX object src-IL/CMakeFiles/IL.dir/src/il_icon.cpp.o
[32/115] Building CXX object src-IL/CMakeFiles/IL.dir/src/il_iwi.cpp.o
[33/115] Building CXX object src-IL/CMakeFiles/IL.dir/src/il_io.cpp.o
[34/115] Building CXX object src-IL/CMakeFiles/IL.dir/src/il_jpeg.cpp.o
[35/115] Building CXX object src-IL/CMakeFiles/IL.dir/src/il_convbuff.cpp.o
ninja: build stopped: subcommand failed.
satmandu commented 1 year ago

Jasper appears to build fine on armv7l w/o this patch! :)

satmandu commented 1 year ago

So maybe there just needs to be an x86_64 ifdef added for this...

tristanjl commented 1 year ago

Shouldn't the types be ssize_t and size_t instead of long int and long unsigned int to match the jas_stream_ops_t struct (and so it will compile 32/64bit)? Also the #endif statements look like they should be higher so the end the new #if block