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

Configuring CGAL with MPFI results in a link error in test_MPFI.cpp, which prevents MPFI from being used successfully. #8673

Open
tanyanhn opened this issue Dec 25, 2024 · 0 comments

Comments

@tanyanhn
Copy link

Describe the bug
MPFI is an optional lib for CGAL for Algebraic Kernel. As a header-only lib, CGAL should be able to use MPFI to configure examples.
However, the configure file "CGAL-6.0.1/cmake/modules/CGAL_UseMPFI.cmake" give a wrong link order
in MPFI_TEST, induce a link error.

Environment

  • OS: ubuntu 22.04
  • Compiler: GCC 13.1.0

To Reproduce
Steps to reproduce the behavior:

  1. cd /path/to/CGAL-6.0.1/examples/Algebraic_kernel_d/build
  2. cmake -DWITH_MPFI=ON -DCMAKE_BUILD_TYPE=Release
    -DGMP_INCLUDE_DIR=$GMP_INCLUDE_DIR
    -DGMP_LIBRARIES=$GMP_LIBRARIES
    -DMPFR_INCLUDE_DIR=$MPFR_INCLUDE_DIR
    -DMPFR_LIBRARIES=$MPFR_LIBRARIES
    -DMPFI_INCLUDE_DIR=$MPFI_INCLUDE_DIR
    -DMPFI_LIBRARIES=$MPFI_LIBRARIES
    -DQT6_DIR=$QT6_DIR
    -DCGAL_DIR=$VCPKG_INSTALL_DIR/share/cgal
    ..
    ...
    -- MPFI libraries: /root/github/install/cgal/vcpkg_installed/x64-linux/lib/libmpfi.a
    -- MPFI is incorrectly configured on this system
    -- Output of the failed MPFI test was:
    Change Dir: /root/github/install/cgal/CGAL-6.0.1/examples/Algebraic_kernel_d/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/gmake -f Makefile cmTC_64239/fast && /usr/bin/gmake -f CMakeFiles/cmTC_64239.dir/build.make CMakeFiles/cmTC_64239.dir/build
gmake[1]: Entering directory '/root/github/install/cgal/CGAL-6.0.1/examples/Algebraic_kernel_d/build/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_64239.dir/test_MPFI.cpp.o
/usr/bin/c++ -I/root/github/install/cgal/vcpkg_installed/x64-linux/include -o CMakeFiles/cmTC_64239.dir/test_MPFI.cpp.o -c /root/github/install/cgal/vcpkg_installed/x64-linux/share/cgal/test_MPFI.cpp
Linking CXX executable cmTC_64239
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_64239.dir/link.txt --verbose=1
/usr/bin/c++ CMakeFiles/cmTC_64239.dir/test_MPFI.cpp.o -o cmTC_64239 -L/root/github/install/cgal/vcpkg_installed/x64-linux/lib/libmpfr.a -Wl,-rpath,/root/github/install/cgal/vcpkg_installed/x64-linux/lib/libmpfr.a /root/github/install/cgal/vcpkg_installed/x64-linux/lib/libmpfi.a /root/github/install/cgal/vcpkg_installed/x64-linux/lib/libgmp.a /root/github/install/cgal/vcpkg_installed/x64-linux/lib/libmpfr.a
/usr/bin/ld: /root/github/install/cgal/vcpkg_installed/x64-linux/lib/libmpfr.a(mpfr-gmp.o): in function mpfr_allocate_func': mpfr-gmp.c:(.text.hot+0x2a): undefined reference to __gmp_get_memory_functions'
/usr/bin/ld: /root/github/install/cgal/vcpkg_installed/x64-linux/lib/libmpfr.a(mpfr-gmp.o): in function mpfr_reallocate_func': mpfr-gmp.c:(.text.hot+0x83): undefined reference to __gmp_get_memory_functions'
/usr/bin/ld: /root/github/install/cgal/vcpkg_installed/x64-linux/lib/libmpfr.a(mpfr-gmp.o): in function mpfr_free_func': mpfr-gmp.c:(.text.hot+0xee): undefined reference to __gmp_get_memory_functions'
/usr/bin/ld: /root/github/install/cgal/vcpkg_installed/x64-linux/lib/libmpfr.a(set_z_2exp.o): in function mpfr_set_z_2exp': set_z_2exp.c:(.text+0x12a): undefined reference to __gmpn_lshift'
/usr/bin/ld: set_z_2exp.c:(.text+0x32c): undefined reference to __gmpn_lshift' /usr/bin/ld: /root/github/install/cgal/vcpkg_installed/x64-linux/lib/libmpfr.a(add1.o): in function mpfr_add1':
add1.c:(.text.hot+0x1b2): undefined reference to __gmpn_rshift' /usr/bin/ld: add1.c:(.text.hot+0x203): undefined reference to __gmpn_add_n'
/usr/bin/ld: add1.c:(.text.hot+0x35d): undefined reference to __gmpn_add_n' /usr/bin/ld: add1.c:(.text.hot+0x42b): undefined reference to __gmpn_rshift'
/usr/bin/ld: add1.c:(.text.hot+0x8b6): undefined reference to __gmpn_rshift' /usr/bin/ld: add1.c:(.text.hot+0xa65): undefined reference to __gmpn_rshift'
/usr/bin/ld: /root/github/install/cgal/vcpkg_installed/x64-linux/lib/libmpfr.a(div.o): in function mpfr_div': div.c:(.text.hot+0x2d7): undefined reference to __gmpn_divrem'
/usr/bin/ld: div.c:(.text.hot+0x62e): undefined reference to __gmpn_rshift' /usr/bin/ld: div.c:(.text.hot+0xa2d): undefined reference to __gmpn_mul'
/usr/bin/ld: div.c:(.text.hot+0xf4f): undefined reference to __gmpn_rshift' /usr/bin/ld: div.c:(.text.hot+0x157e): undefined reference to __gmpn_rshift'
/usr/bin/ld: div.c:(.text.hot+0x1602): undefined reference to __gmpn_mul' /usr/bin/ld: div.c:(.text.hot+0x166f): undefined reference to __gmpn_sub_n'
/usr/bin/ld: div.c:(.text.hot+0x1ad1): undefined reference to __gmpn_add_n' /usr/bin/ld: /root/github/install/cgal/vcpkg_installed/x64-linux/lib/libmpfr.a(div_ui.o): in function mpfr_div_ui':
div_ui.c:(.text.hot+0x12c): undefined reference to __gmpn_divrem_1' /usr/bin/ld: div_ui.c:(.text.hot+0x34f): undefined reference to __gmpn_lshift'
/usr/bin/ld: div_ui.c:(.text.hot+0x3d2): undefined reference to __gmpn_divrem_1' /usr/bin/ld: /root/github/install/cgal/vcpkg_installed/x64-linux/lib/libmpfr.a(round_prec.o): in function mpfr_round_raw':
round_prec.c:(.text+0x20d): undefined reference to __gmpn_copyd' /usr/bin/ld: round_prec.c:(.text+0x24d): undefined reference to __gmpn_copyi'
/usr/bin/ld: round_prec.c:(.text+0x4d7): undefined reference to __gmpn_copyi' /usr/bin/ld: /root/github/install/cgal/vcpkg_installed/x64-linux/lib/libmpfr.a(round_prec.o): in function mpfr_round_raw_4':
round_prec.c:(.text+0x98b): undefined reference to __gmpn_copyi' /usr/bin/ld: round_prec.c:(.text+0xa26): undefined reference to __gmpn_copyd'
/usr/bin/ld: /root/github/install/cgal/vcpkg_installed/x64-linux/lib/libmpfr.a(sub1.o): in function mpfr_sub1': sub1.c:(.text+0x194): undefined reference to __gmpn_rshift'
/usr/bin/ld: sub1.c:(.text+0x246): undefined reference to __gmpn_rshift' /usr/bin/ld: sub1.c:(.text+0x910): undefined reference to __gmpn_sub_n'
/usr/bin/ld: sub1.c:(.text+0xa3a): undefined reference to __gmpn_sub_n' /usr/bin/ld: sub1.c:(.text+0xad0): undefined reference to __gmpn_sub_n'
/usr/bin/ld: sub1.c:(.text+0xbdc): undefined reference to __gmpn_sub_n' /usr/bin/ld: /root/github/install/cgal/vcpkg_installed/x64-linux/lib/libmpfr.a(sub1sp.o): in function mpfr_sub1sp':
sub1sp.c:(.text.hot+0x187): undefined reference to __gmpn_rshift' /usr/bin/ld: sub1sp.c:(.text.hot+0x25a): undefined reference to __gmpn_sub_n'
/usr/bin/ld: sub1sp.c:(.text.hot+0x55f): undefined reference to __gmpn_sub_n' /usr/bin/ld: sub1sp.c:(.text.hot+0x597): undefined reference to __gmpn_lshift'
/usr/bin/ld: sub1sp.c:(.text.hot+0xb0a): undefined reference to __gmpn_lshift' /usr/bin/ld: sub1sp.c:(.text.hot+0xb1c): undefined reference to __gmpn_sub_n'
/usr/bin/ld: sub1sp.c:(.text.hot+0xfe2): undefined reference to __gmpn_rshift' /usr/bin/ld: sub1sp.c:(.text.hot+0x1000): undefined reference to __gmpn_sub_n'
/usr/bin/ld: sub1sp.c:(.text.hot+0x19f7): undefined reference to __gmpn_lshift' /usr/bin/ld: sub1sp.c:(.text.hot+0x1ad5): undefined reference to __gmpn_lshift'
/usr/bin/ld: sub1sp.c:(.text.hot+0x1b2d): undefined reference to __gmpn_rshift' /usr/bin/ld: sub1sp.c:(.text.hot+0x1ec5): undefined reference to __gmpn_copyd'
/usr/bin/ld: /root/github/install/cgal/vcpkg_installed/x64-linux/lib/libmpfr.a(add1sp.o): in function mpfr_add1sp': add1sp.c:(.text.hot+0x1e2): undefined reference to __gmpn_add_n'
/usr/bin/ld: add1sp.c:(.text.hot+0x86d): undefined reference to __gmpn_add_n' /usr/bin/ld: add1sp.c:(.text.hot+0x89d): undefined reference to __gmpn_rshift'
/usr/bin/ld: add1sp.c:(.text.hot+0x1342): undefined reference to __gmpn_rshift' /usr/bin/ld: add1sp.c:(.text.hot+0x1714): undefined reference to __gmpn_add_n'
/usr/bin/ld: /root/github/install/cgal/vcpkg_installed/x64-linux/lib/libmpfr.a(init2.o): in function mpfr_init2': init2.c:(.text.hot+0x7): undefined reference to __gmp_bits_per_limb'
/usr/bin/ld: /root/github/install/cgal/vcpkg_installed/x64-linux/lib/libmpfr.a(pool.o): in function mpfr_free_pool': pool.c:(.text+0x3b): undefined reference to __gmpz_clear'
/usr/bin/ld: /root/github/install/cgal/vcpkg_installed/x64-linux/lib/libmpfr.a(pool.o): in function mpfr_mpz_init': pool.c:(.text.hot+0x4d): undefined reference to __gmpz_init'
/usr/bin/ld: /root/github/install/cgal/vcpkg_installed/x64-linux/lib/libmpfr.a(pool.o): in function mpfr_mpz_init2': pool.c:(.text.hot+0xcd): undefined reference to __gmpz_init2'
/usr/bin/ld: /root/github/install/cgal/vcpkg_installed/x64-linux/lib/libmpfr.a(pool.o): in function mpfr_mpz_clear': pool.c:(.text.hot+0x125): undefined reference to __gmpz_clear'
/usr/bin/ld: /root/github/install/cgal/vcpkg_installed/x64-linux/lib/libmpfr.a(set_q.o): in function set_z': set_q.c:(.text+0x87): undefined reference to __gmpn_lshift'
/usr/bin/ld: /root/github/install/cgal/vcpkg_installed/x64-linux/lib/libmpfr.a(min_prec.o): in function mpfr_min_prec': min_prec.c:(.text+0x1f): undefined reference to __gmpn_scan1'
/usr/bin/ld: /root/github/install/cgal/vcpkg_installed/x64-linux/lib/libmpfr.a(mulders.o): in function mpfr_mulhigh_n.localalias': mulders.c:(.text+0x80): undefined reference to __gmpn_mul_n'
/usr/bin/ld: mulders.c:(.text+0xd6): undefined reference to __gmpn_add_n' /usr/bin/ld: mulders.c:(.text+0x10d): undefined reference to __gmpn_add_n'
/usr/bin/ld: mulders.c:(.text+0x1d7): undefined reference to __gmpn_addmul_1' /usr/bin/ld: /root/github/install/cgal/vcpkg_installed/x64-linux/lib/libmpfr.a(mulders.o): in function mpfr_sqrhigh_n':
mulders.c:(.text+0x2c2): undefined reference to __gmpn_sqr' /usr/bin/ld: mulders.c:(.text+0x2ec): undefined reference to __gmpn_lshift'
/usr/bin/ld: mulders.c:(.text+0x307): undefined reference to __gmpn_add_n' /usr/bin/ld: mulders.c:(.text+0x3c7): undefined reference to __gmpn_addmul_1'
/usr/bin/ld: /root/github/install/cgal/vcpkg_installed/x64-linux/lib/libmpfr.a(mulders.o): in function mpfr_divhigh_n.localalias': mulders.c:(.text+0x49b): undefined reference to __gmpn_divrem'
/usr/bin/ld: mulders.c:(.text+0x53e): undefined reference to __gmpn_sub_n' /usr/bin/ld: mulders.c:(.text+0x5bf): undefined reference to __gmpn_add_n'
/usr/bin/ld: mulders.c:(.text+0x661): undefined reference to __gmpn_sub_n' /usr/bin/ld: mulders.c:(.text+0x6b1): undefined reference to __gmpn_sub_n'
/usr/bin/ld: mulders.c:(.text+0x7bf): undefined reference to __gmpn_submul_1' /usr/bin/ld: mulders.c:(.text+0x81c): undefined reference to __gmpn_add_n'
/usr/bin/ld: /root/github/install/cgal/vcpkg_installed/x64-linux/lib/libmpfr.a(mulders.o): in function mpfr_mulhigh_n.localalias': mulders.c:(.text+0x184): undefined reference to __gmpn_mul'
/usr/bin/ld: mulders.c:(.text+0x247): undefined reference to __gmpn_mul_n' /usr/bin/ld: /root/github/install/cgal/vcpkg_installed/x64-linux/lib/libmpfr.a(mulders.o): in function mpfr_sqrhigh_n':
mulders.c:(.text+0x376): undefined reference to __gmpn_sqr' /usr/bin/ld: /root/github/install/cgal/vcpkg_installed/x64-linux/lib/libmpfr.a(ubf.o): in function mpfr_ubf_mul_exact':
ubf.c:(.text+0x142): undefined reference to __gmpz_set_si' /usr/bin/ld: ubf.c:(.text+0x16e): undefined reference to __gmpz_set_si'
/usr/bin/ld: ubf.c:(.text+0x17c): undefined reference to __gmpz_add' /usr/bin/ld: ubf.c:(.text+0x19a): undefined reference to __gmpz_sub_ui'
/usr/bin/ld: ubf.c:(.text+0x1fa): undefined reference to __gmpn_mul' /usr/bin/ld: ubf.c:(.text+0x213): undefined reference to __gmpn_lshift'
/usr/bin/ld: ubf.c:(.text+0x238): undefined reference to __gmpz_set' /usr/bin/ld: ubf.c:(.text+0x250): undefined reference to __gmpz_set'
/usr/bin/ld: ubf.c:(.text+0x26d): undefined reference to __gmpn_mul' /usr/bin/ld: ubf.c:(.text+0x2e7): undefined reference to __gmpn_sqr'
/usr/bin/ld: /root/github/install/cgal/vcpkg_installed/x64-linux/lib/libmpfr.a(ubf.o): in function mpfr_ubf_exp_less_p': ubf.c:(.text+0x3a4): undefined reference to __gmpz_set_si'
/usr/bin/ld: ubf.c:(.text+0x3cc): undefined reference to __gmpz_set_si' /usr/bin/ld: ubf.c:(.text+0x3d7): undefined reference to __gmpz_cmp'
/usr/bin/ld: ubf.c:(.text+0x418): undefined reference to __gmpz_set' /usr/bin/ld: ubf.c:(.text+0x428): undefined reference to __gmpz_set'
/usr/bin/ld: /root/github/install/cgal/vcpkg_installed/x64-linux/lib/libmpfr.a(ubf.o): in function mpfr_ubf_diff_exp': ubf.c:(.text+0x5a5): undefined reference to __gmpz_set_si'
/usr/bin/ld: ubf.c:(.text+0x5cd): undefined reference to __gmpz_set_si' /usr/bin/ld: ubf.c:(.text+0x5db): undefined reference to __gmpz_sub'
/usr/bin/ld: ubf.c:(.text+0x629): undefined reference to __gmpz_set' /usr/bin/ld: ubf.c:(.text+0x640): undefined reference to __gmpz_set'
collect2: error: ld returned 1 exit status
gmake[1]: *** [CMakeFiles/cmTC_64239.dir/build.make:102: cmTC_64239] Error 1
gmake[1]: Leaving directory '/root/github/install/cgal/CGAL-6.0.1/examples/Algebraic_kernel_d/build/CMakeFiles/CMakeTmp'
gmake: *** [Makefile:127: cmTC_64239/fast] Error 2

-- End of the MPFI test output
-- Configuring done
...
Repro code when

Expected behavior
A clear and concise description of what you expected to happen.
After swap {GMP_LIBRARIES} and {MPFR_LIBRARIES} order in CGAL-6.0.1/cmake/modules/CGAL_UseMPFI.cmake c:20-24.
"-DLINK_LIBRARIES:
STRING=${MPFI_LIBRARIES};${GMP_LIBRARIES};${MPFR_LIBRARIES}"
"-DLINK_DIRECTORIES:
STRING=${MPFI_LIBRARIES_DIR};${GMP_LIBRARIES_DIRS};${MPFR_LIBRARIES}"

cmake have a correct output:
-- MPFI libraries: /root/github/install/cgal/vcpkg_installed/x64-linux/lib/libmpfi.a
-- Configuring done

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

1 participant