Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

latest version of jasper causes build to break #245

Closed
edwardhartnett opened this issue Apr 14, 2022 · 4 comments · Fixed by #246
Closed

latest version of jasper causes build to break #245

edwardhartnett opened this issue Apr 14, 2022 · 4 comments · Fixed by #246
Assignees
Labels

Comments

@edwardhartnett
Copy link
Contributor

edwardhartnett commented Apr 14, 2022

With jasper-3.0.3:

[ 47%] Building C object CMakeFiles/g2c.dir/src/dec_jpeg2000.c.o
In file included from /usr/local/jasper-3.0.3/include/jasper/jasper.h:73,
                 from /home/ed/NCEPLIBS-g2c/src/dec_jpeg2000.c:10:
/usr/local/jasper-3.0.3/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."
      |  ^~~~~~~
[ 48%] Building C object CMakeFiles/g2c.dir/src/enc_jpeg2000.c.o
In file included from /usr/local/jasper-3.0.3/include/jasper/jasper.h:73,
                 from /home/ed/NCEPLIBS-g2c/src/enc_jpeg2000.c:9:
/usr/local/jasper-3.0.3/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."
      |  ^~~~~~~
[ 50%] Building C object CMakeFiles/g2c.dir/src/jpcpack.c.o
[ 51%] Building C object CMakeFiles/g2c.dir/src/jpcunpack.c.o
[ 52%] Linking C static library libg2c.a
[ 52%] Built target g2c
[ 53%] Building C object tests/CMakeFiles/tst_addfield3.dir/tst_addfield3.c.o
[ 54%] Linking C executable tst_addfield3
/usr/bin/ld: ../libg2c.a(dec_jpeg2000.c.o): in function `dec_jpeg2000':
/home/ed/NCEPLIBS-g2c/src/dec_jpeg2000.c:46: undefined reference to `jpc_decode'
/usr/bin/ld: ../libg2c.a(enc_jpeg2000.c.o): in function `enc_jpeg2000':
/home/ed/NCEPLIBS-g2c/src/enc_jpeg2000.c:104: undefined reference to `jpc_encode'
collect2: error: ld returned 1 exit status
make[2]: *** [tests/CMakeFiles/tst_addfield3.dir/build.make:89: tests/tst_addfield3] Error 1
make[1]: *** [CMakeFiles/Makefile2:968: tests/CMakeFiles/tst_addfield3.dir/all] Error 2
make: *** [Makefile:141: all] Error 2
ed@mikado:~/NCEPLIBS-g2c/b$ 
@edwardhartnett
Copy link
Contributor Author

edwardhartnett commented Apr 14, 2022

The warning is coming from here: /usr/local/jasper-3.0.3/include/jasper/jas_config.h

Which has:

#if (__STDC_VERSION__ - 0 < JAS_STDC_VERSION)
#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."
#endif

Also:

/*
The version of the C standard against which JasPer was built.
*/
#define JAS_STDC_VERSION 201112L

When I check __STDC_VERSION__ I see that it is later than the Jasper one.

gcc -dM -E - < /dev/null | grep "__STDC_"

#define __STDC_HOSTED__ 1
#define __STDC_UTF_16__ 1
#define __STDC_IEC_559__ 1
#define __STDC_ISO_10646__ 201706L
#define __STDC_IEC_559_COMPLEX__ 1
#define __STDC_VERSION__ 201710L
#define __STDC_UTF_32__ 1
#define __STDC__ 1

This seems like japser dumbness in some way. Firstly I built jasper yesterday with the exact same compiler, so why is JAS_STDC_VERSION different from __STDC_VERSION__?

Secondly, why is the warning happening when __STDC_VERSION__ is actually greater than JAS_STDC_VERSION?

@edwardhartnett
Copy link
Contributor Author

Here's some preprocessor code I used to debug the problem of warnings:

#define XSTR(x) STR(x)
#define STR(x) #x
#pragma message "The value of __STDC_VERSION__ is: " XSTR(__STDC_VERSION__)
#pragma message "The value of JAS_STDC_VERSION is: " XSTR(JAS_STDC_VERSION)


Turns out the problem is in the g2c CMakefile.txt:

set_property(TARGET ${lib_name} PROPERTY C_STANDARD 99)
Should be:

set_property(TARGET ${lib_name} PROPERTY C_STANDARD 11)

@edwardhartnett
Copy link
Contributor Author

Seems like the functions we are using, jpc_encode() and jpc_decode() are internal functions of Jasper that we should not be using. Seems like the author wants us to use jas_image_encode()/jas_image_decode() instead.

The jpc functions are not documented in the jasper documentation.

@edwardhartnett
Copy link
Contributor Author

edwardhartnett commented Apr 15, 2022

OK, the problem is that jpc_encode/jpc_decode are no longer exported functions of the library.

ed@mikado:~/Downloads$ find /usr/local/jasper-3.0.3/include/jasper/ -name '*.h'|xargs grep jpc_encode
/usr/local/jasper-3.0.3/include/jasper/jas_image.h:int jpc_encode(jas_image_t *image, jas_stream_t *out, const char *optstr);
ed@mikado:~/Downloads$ find /usr/local/jasper-2.0.33/include/jasper/ -name '*.h'|xargs grep jpc_encode
/usr/local/jasper-2.0.33/include/jasper/jas_image.h:JAS_DLLEXPORT int jpc_encode(jas_image_t *image, jas_stream_t *out, const char *optstr);

I think the answer here is to use the jas_image_encode/jas_image_decode instead. These are the public functions we are supposed to be using, according to the jasper documentation.

I also see in the release notes for jasper-3.0.0:

More effort has been made to hide functions/macros that are internal to the JasPer library in an effort to prevent applications using such functions/macros (which can lead to many types of problems).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant