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

Building the java wrapper: "conflicting types for ‘Java_gmp_Mpfr_jn’" #53

Closed
AronSchnakenbeck opened this issue Oct 20, 2022 · 4 comments

Comments

@AronSchnakenbeck
Copy link

Hi, I'm trying to build the java wrapper on windows:

$ make
(cd num; make all)
make[1]: Entering directory '/cygdrive/d/apron-0.9.13/apron-0.9.13/num'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/cygdrive/d/apron-0.9.13/apron-0.9.13/num'
(cd itv; make all)
make[1]: Entering directory '/cygdrive/d/apron-0.9.13/apron-0.9.13/itv'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/cygdrive/d/apron-0.9.13/apron-0.9.13/itv'
(cd apron; make all)
make[1]: Entering directory '/cygdrive/d/apron-0.9.13/apron-0.9.13/apron'
x86_64-w64-mingw32-gcc.exe  -I../num -I../itv -I/usr/include -E -MM ap_scalar.c ap_interval.c ap_coeff.c ap_dimension.c ap_linexpr0.c ap_lincons0.c ap_generator0.c ap_texpr0.c ap_tcons0.c ap_manager.c ap_abstract0.c ap_policy.c ap_generic.c ap_var.c ap_environment.c ap_linexpr1.c ap_lincons1.c ap_generator1.c ap_texpr1.c ap_tcons1.c ap_abstract1.c ap_linearize.c ap_reducedproduct.c ap_disjunction.c  > depend
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/cygdrive/d/apron-0.9.13/apron-0.9.13/apron'
(cd newpolka; make all)
make[1]: Entering directory '/cygdrive/d/apron-0.9.13/apron-0.9.13/newpolka'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/cygdrive/d/apron-0.9.13/apron-0.9.13/newpolka'
(cd box; make all)
make[1]: Entering directory '/cygdrive/d/apron-0.9.13/apron-0.9.13/box'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/cygdrive/d/apron-0.9.13/apron-0.9.13/box'
(cd octagons; make MPQ D)
make[1]: Entering directory '/cygdrive/d/apron-0.9.13/apron-0.9.13/octagons'
make[1]: Nothing to be done for 'MPQ'.
make[1]: Nothing to be done for 'D'.
make[1]: Leaving directory '/cygdrive/d/apron-0.9.13/apron-0.9.13/octagons'
(cd taylor1plus; make all)
make[1]: Entering directory '/cygdrive/d/apron-0.9.13/apron-0.9.13/taylor1plus'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/cygdrive/d/apron-0.9.13/apron-0.9.13/taylor1plus'
(cd japron; make)
make[1]: Entering directory '/cygdrive/d/apron-0.9.13/apron-0.9.13/japron'
x86_64-w64-mingw32-gcc.exe -Wcast-qual -Wswitch -Werror-implicit-function-declaration -Wall -Wextra -Wundef -Wbad-function-cast -Wcast-align -Wstrict-prototypes -Wno-unused -Wno-unused-parameter -Wno-unused-function -std=c99 -U__STRICT_ANSI__ -fPIC -O3 -DNDEBUG -Wno-int-to-pointer-cast -Wno-pointer-to-int-cast -Wno-bad-function-cast -c  -I/usr/include -I/usr/include -I/usr/include -IC:\Program Files\Java\jdk-16.0.1/include -IC:\Program Files\Java\jdk-16.0.1/include/linux -I../apron -I../box -I../newpolka -I../octagons -I../ppl -I../products -I C:\Program\ Files\Java\jdk1.8.0_291\include -I C:\Program\ Files\Java\jdk1.8.0_291\include\win32  gmp/gmp_Mpfr.c -o gmp/gmp_Mpfr.o
gmp/gmp_Mpfr.c: In function ‘Java_gmp_Mpfr_root’:
gmp/gmp_Mpfr.c:830:3: warning: ‘mpfr_root’ is deprecated [-Wdeprecated-declarations]
  830 |   return mpfr_root(as_mpfr(o1), as_mpfr(o2), i, p);
      |   ^~~~~~
In file included from gmp/jgmp.h:16,
                 from gmp/gmp_Mpfr.c:11:
/usr/x86_64-w64-mingw32/sys-root/mingw/include/mpfr.h:727:21: note: declared here
  727 | __MPFR_DECLSPEC int mpfr_root (mpfr_ptr, mpfr_srcptr, unsigned long,
      |                     ^~~~~~~~~
gmp/gmp_Mpfr.c: At top level:
gmp/gmp_Mpfr.c:1729:24: error: conflicting types for ‘Java_gmp_Mpfr_jn’; have ‘jint(const struct JNINativeInterface_ **, struct _jobject *, int,  struct _jobject *, jint)’ {aka ‘long int(const struct JNINativeInterface_ **, struct _jobject *, int,  struct _jobject *, long int)’}
 1729 | JNIEXPORT jint JNICALL Java_gmp_Mpfr_jn
      |                        ^~~~~~~~~~~~~~~~
In file included from gmp/gmp_Mpfr.c:12:
gmp/gmp_Mpfr.h:1039:24: note: previous declaration of ‘Java_gmp_Mpfr_jn’ with type ‘jint(const struct JNINativeInterface_ **, struct _jobject *, jint,  struct _jobject *, jint)’ {aka ‘long int(const struct JNINativeInterface_ **, struct _jobject *, long int,  struct _jobject *, long int)’}
 1039 | JNIEXPORT jint JNICALL Java_gmp_Mpfr_jn
      |                        ^~~~~~~~~~~~~~~~
make[1]: *** [Makefile:133: gmp/gmp_Mpfr.o] Error 1
make[1]: Leaving directory '/cygdrive/d/apron-0.9.13/apron-0.9.13/japron'
make: *** [Makefile:35: java] Error 2

Since I' not really familiar with C I don't know how to fix it. Can somebody help me?

@antoinemine
Copy link
Owner

Thank you for the report.

PR #54 should fix the problem.

Could you please check that it works and there are no additional issues on Windows before I merge ?

@AronSchnakenbeck
Copy link
Author

Thanks for the response!

I guess the PR fixed that issue, but I'm struggling now with other issues:

When i clone the branch form PR #54 I get:

$ make
(cd num; make all)
make[1]: Entering directory '/cygdrive/d/apron-git/apron/num'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/cygdrive/d/apron-git/apron/num'
(cd itv; make all)
make[1]: Entering directory '/cygdrive/d/apron-git/apron/itv'
ar rcs libitvMPQ.a itvMPQ.o itv_linexprMPQ.o itv_linearizeMPQ.o
make[1]: ar: No such file or directory
make[1]: *** [Makefile:102: libitvMPQ.a] Error 127
make[1]: Leaving directory '/cygdrive/d/apron-git/apron/itv'
make: *** [Makefile:20: c] Error 2

Which is strange, because I didn't get the error trying it the first time (with the same Makefile.config).
When I do the fix #54 manually in the first build (where the libitvMPQ.a files etc. are already build), I get:

$ make
(cd num; make all)
make[1]: Entering directory '/cygdrive/d/apron-0.9.13/apron-0.9.13/num'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/cygdrive/d/apron-0.9.13/apron-0.9.13/num'
(cd itv; make all)
make[1]: Entering directory '/cygdrive/d/apron-0.9.13/apron-0.9.13/itv'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/cygdrive/d/apron-0.9.13/apron-0.9.13/itv'
(cd apron; make all)
make[1]: Entering directory '/cygdrive/d/apron-0.9.13/apron-0.9.13/apron'
x86_64-w64-mingw32-gcc.exe  -I../num -I../itv -I/usr/include -E -MM ap_scalar.c ap_interval.c ap_coeff.c ap_dimension.c ap_linexpr0.c ap_lincons0.c ap_generator0.c ap_texpr0.c ap_tcons0.c ap_manager.c ap_abstract0.c ap_policy.c ap_generic.c ap_var.c ap_environment.c ap_linexpr1.c ap_lincons1.c ap_generator1.c ap_texpr1.c ap_tcons1.c ap_abstract1.c ap_linearize.c ap_reducedproduct.c ap_disjunction.c  > depend
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/cygdrive/d/apron-0.9.13/apron-0.9.13/apron'
(cd newpolka; make all)
make[1]: Entering directory '/cygdrive/d/apron-0.9.13/apron-0.9.13/newpolka'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/cygdrive/d/apron-0.9.13/apron-0.9.13/newpolka'
(cd box; make all)
make[1]: Entering directory '/cygdrive/d/apron-0.9.13/apron-0.9.13/box'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/cygdrive/d/apron-0.9.13/apron-0.9.13/box'
(cd octagons; make MPQ D)
make[1]: Entering directory '/cygdrive/d/apron-0.9.13/apron-0.9.13/octagons'
make[1]: Nothing to be done for 'MPQ'.
make[1]: Nothing to be done for 'D'.
make[1]: Leaving directory '/cygdrive/d/apron-0.9.13/apron-0.9.13/octagons'
(cd taylor1plus; make all)
make[1]: Entering directory '/cygdrive/d/apron-0.9.13/apron-0.9.13/taylor1plus'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/cygdrive/d/apron-0.9.13/apron-0.9.13/taylor1plus'
(cd japron; make)
make[1]: Entering directory '/cygdrive/d/apron-0.9.13/apron-0.9.13/japron'
x86_64-w64-mingw32-gcc.exe -Wcast-qual -Wswitch -Werror-implicit-function-declaration -Wall -Wextra -Wundef -Wbad-function-cast -Wcast-align -Wstrict-prototypes -Wno-unused -Wno-unused-parameter -Wno-unused-function -std=c99 -U__STRICT_ANSI__ -fPIC -O3 -DNDEBUG -Wno-int-to-pointer-cast -Wno-pointer-to-int-cast -Wno-bad-function-cast -c  -I/usr/include -I/usr/include -I/usr/include -IC:\Program Files\Java\jdk-16.0.1/include -IC:\Program Files\Java\jdk-16.0.1/include/linux -I../apron -I../box -I../newpolka -I../octagons -I../ppl -I../products -I C:\Program\ Files\Java\jdk1.8.0_291\include -I C:\Program\ Files\Java\jdk1.8.0_291\include\win32  -Igmp apron/apron_Dimperm.c -o apron/apron_Dimperm.o
x86_64-w64-mingw32-gcc: warning: Files\Java\jdk-16.0.1/include: linker input file unused because linking not done
x86_64-w64-mingw32-gcc: error: Files\Java\jdk-16.0.1/include: linker input file not found: No such file or directory
x86_64-w64-mingw32-gcc: warning: Files\Java\jdk-16.0.1/include/linux: linker input file unused because linking not done
x86_64-w64-mingw32-gcc: error: Files\Java\jdk-16.0.1/include/linux: linker input file not found: No such file or directory
make[1]: *** [Makefile:157: apron/apron_Dimperm.o] Error 1
make[1]: Leaving directory '/cygdrive/d/apron-0.9.13/apron-0.9.13/japron'
make: *** [Makefile:35: java] Error 2

Removing -I${JAVA_HOME}/include \ -I${JAVA_HOME}/include/linux \ from /japron/Makefile I get:

$ make
(cd num; make all)
make[1]: Entering directory '/cygdrive/d/apron-0.9.13/apron-0.9.13/num'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/cygdrive/d/apron-0.9.13/apron-0.9.13/num'
(cd itv; make all)
make[1]: Entering directory '/cygdrive/d/apron-0.9.13/apron-0.9.13/itv'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/cygdrive/d/apron-0.9.13/apron-0.9.13/itv'
(cd apron; make all)
make[1]: Entering directory '/cygdrive/d/apron-0.9.13/apron-0.9.13/apron'
x86_64-w64-mingw32-gcc.exe  -I../num -I../itv -I/usr/include -E -MM ap_scalar.c ap_interval.c ap_coeff.c ap_dimension.c ap_linexpr0.c ap_lincons0.c ap_generator0.c ap_texpr0.c ap_tcons0.c ap_manager.c ap_abstract0.c ap_policy.c ap_generic.c ap_var.c ap_environment.c ap_linexpr1.c ap_lincons1.c ap_generator1.c ap_texpr1.c ap_tcons1.c ap_abstract1.c ap_linearize.c ap_reducedproduct.c ap_disjunction.c  > depend
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/cygdrive/d/apron-0.9.13/apron-0.9.13/apron'
(cd newpolka; make all)
make[1]: Entering directory '/cygdrive/d/apron-0.9.13/apron-0.9.13/newpolka'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/cygdrive/d/apron-0.9.13/apron-0.9.13/newpolka'
(cd box; make all)
make[1]: Entering directory '/cygdrive/d/apron-0.9.13/apron-0.9.13/box'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/cygdrive/d/apron-0.9.13/apron-0.9.13/box'
(cd octagons; make MPQ D)
make[1]: Entering directory '/cygdrive/d/apron-0.9.13/apron-0.9.13/octagons'
make[1]: Nothing to be done for 'MPQ'.
make[1]: Nothing to be done for 'D'.
make[1]: Leaving directory '/cygdrive/d/apron-0.9.13/apron-0.9.13/octagons'
(cd taylor1plus; make all)
make[1]: Entering directory '/cygdrive/d/apron-0.9.13/apron-0.9.13/taylor1plus'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/cygdrive/d/apron-0.9.13/apron-0.9.13/taylor1plus'
(cd japron; make)
make[1]: Entering directory '/cygdrive/d/apron-0.9.13/apron-0.9.13/japron'
x86_64-w64-mingw32-gcc.exe -Wcast-qual -Wswitch -Werror-implicit-function-declaration -Wall -Wextra -Wundef -Wbad-function-cast -Wcast-align -Wstrict-prototypes -Wno-unused -Wno-unused-parameter -Wno-unused-function -std=c99 -U__STRICT_ANSI__ -fPIC -O3 -DNDEBUG -Wno-int-to-pointer-cast -Wno-pointer-to-int-cast -Wno-bad-function-cast -c  -I/usr/include -I/usr/include -I/usr/include  -Igmp apron/apron_Linexpr0.c -o apron/apron_Linexpr0.o
In file included from apron/japron.h:11,
                 from apron/apron_Linexpr0.c:11:
gmp/jgmp.h:17:10: fatal error: jni.h: No such file or directory
   17 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
make[1]: *** [Makefile:157: apron/apron_Linexpr0.o] Error 1
make[1]: Leaving directory '/cygdrive/d/apron-0.9.13/apron-0.9.13/japron'
make: *** [Makefile:35: java] Error 2

So i guess i haven't set the JININC variable in Makefile.confing correctly:

JNIINC    = -I C:\Program\ Files\Java\jdk1.8.0_291\include -I C:\Program\ Files\Java\jdk1.8.0_291\include\win32

Right now i can't figure out the the correct syntax (the syntax is correct e.g. for the JAVA variable, but i guess the -I makes a difference). Maybe a windows specific example in the readme would be helpful.

@antoinemine
Copy link
Owner

Please make sure that you build from a clean repository (fresh directory, not one containing a previous version). There is configure script to fill in the Makefile.config file (but I cannot guarantee that it works currently on Windows, I'm sorry).

@AronSchnakenbeck
Copy link
Author

I switched to linux which worked much better.

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

No branches or pull requests

2 participants