Undefined symbol "___gmpz_set"

28 views
Skip to first unread message

Maciej Radziejewski

unread,
May 21, 2024, 9:29:18 AMMay 21
to flint-devel
Hello,

I am trying to start using Flint on MacOS 12.7.5 (Intel Mac with with Homebrew) and I struggle to compile the example program zeta_zeros.c. I say:

gcc zeta_zeros.c -lflint -I/usr/local/include/flint -L/usr/local/lib -o./zeta_zeros


and I get:

Undefined symbols for architecture x86_64:

  "___gmpz_set", referenced from:

      _fmpz_init_set in zeta_zeros-14997c.o

ld: symbol(s) not found for architecture x86_64

clang: error: linker command failed with exit code 1 (use -v to see invocation)


Could anyone help me?

Compiling a simple example from
worked fine. I was also able to compile and run other example programs like integrals.c, crt.c, fmpz_poly_q.

From the Arb examples I successfully ran:
logistic.c, poly_roots.c, integrals.c, fpwrap.c, functions_benchmark.c.
Compiling lvalue.c reports another undefined symbol: "___gmpn_gcd_11".
All other Arb examples, when run, fail with "Segmentation fault 11".

Btw, what would be the typical Unix flavour to run Flint on? Is installation more straightforward there?

Thanks,
Maciej


Albin Ahlbäck

unread,
May 21, 2024, 9:33:22 AMMay 21
to flint...@googlegroups.com, Maciej Radziejewski
Hello Maciej,

Although it could be stated in the documentation more clearly, it states
in the link you provided that you may need to push `-lgmp' and possibly
`-lmpfr' to GCC. This is the case for you.

Regarding the Unix flavors, any flavor will do just fine.

Best,
Albin

On 5/21/24 3:26 PM, Maciej Radziejewski wrote:
> Hello,
>
> I am trying to start using Flint on MacOS 12.7.5 (Intel Mac with with
> Homebrew) and I struggle to compile the example program zeta_zeros.c. I say:
>
> gcc zeta_zeros.c -lflint -I/usr/local/include/flint -L/usr/local/lib
> -o./zeta_zeros
>
>
> and I get:
>
> Undefined symbols for architecture x86_64:
>
>   "___gmpz_set", referenced from:
>
>       _fmpz_init_set in zeta_zeros-14997c.o
>
> ld: symbol(s) not found for architecture x86_64
>
> clang: *error: *linker command failed with exit code 1 (use -v to see
> invocation)
>
>
> Could anyone help me?
>
> Compiling a simple example from
> https://flintlib.org/doc/building.html#linking-and-running-code
> <https://flintlib.org/doc/building.html#linking-and-running-code>
> worked fine. I was also able to compile and run other example programs
> like integrals.c, crt.c, fmpz_poly_q.
>
> From the Arb examples I successfully ran:
> logistic.c, poly_roots.c, integrals.c, fpwrap.c, functions_benchmark.c.
> Compiling lvalue.c reports another undefined symbol: "___gmpn_gcd_11".
> All other Arb examples, when run, fail with "Segmentation fault 11".
>
> Btw, what would be the typical Unix flavour to run Flint on? Is
> installation more straightforward there?
>
> Thanks,
> Maciej
>
>
> --
>
> ---
> You received this message because you are subscribed to the Google
> Groups "flint-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to flint-devel...@googlegroups.com
> <mailto:flint-devel...@googlegroups.com>.
> To view this discussion on the web, visit
> https://groups.google.com/d/msgid/flint-devel/f573b3ad-9b4f-4a1b-8f9b-55b3a636619cn%40googlegroups.com <https://groups.google.com/d/msgid/flint-devel/f573b3ad-9b4f-4a1b-8f9b-55b3a636619cn%40googlegroups.com?utm_medium=email&utm_source=footer>.

Maciej Radziejewski

unread,
May 22, 2024, 4:38:53 AMMay 22
to flint-devel
Hello Albin,

Thank you for your prompt reply! Indeed, adding -lmpfr -lgmp solved the problems. In addition I needed to enter

export MACOSX_DEPLOYMENT_TARGET=$(sw_vers -productVersion)

to avoid warnings that dylib (/usr/local/lib/libflint.dylib) was built for newer macOS version (12.0) than being linked (11.0). This may be a Homebrew-specific thing. I will report it there.

It is great to have such easy access to the zeros of Riemann zeta. Thanks!

I would suggest two changes to the doc page

First, the sentence " You may also have to pass the flags -lmpfr and -lgmp to the compiler " could be changed to:

For more advanced programs you may have to pass the flags
[code snippet]
-lmpfr -lgmp
[/code snippet]
to the compiler.

Reason: these flags are actually not needed to compile test.c, and they should be made more visible. Second, I would start the "Quick start" with a note like this (I did not test MSYS2):

Many Linux flavours include package managers where Flint is ready to be installed automatically with all its dependencies. Package names and available Flint versions vary, so you need to search the packages list of your distribution. If you take that route, you will be missing the examples folder, but you can extract it from the full Flint download available here.  For Mac check out MacPorts or Homebrew, and for Windows MSYS2. Then see [#linking-and-running-code] below. If you wish to have more control, you can install Flint manually, as described here. 

Thanks,
Maciej

Albin Ahlbäck

unread,
May 22, 2024, 5:55:37 AMMay 22
to flint...@googlegroups.com, Maciej Radziejewski
Hello Maciej,

I believe neither me or Fredrik are responsible for any FLINT releases
on any package managers, and therefore it is my opinion that we should
avoid to make any such recommendations as we do not know if it has been
installed correctly.

However, I believe that Edgar Costa has sent some patches for Homebrew,
but I'm unsure whether he is the package maintainer there or if he has
just sent some patches there.

Regardless, would you be able to send a git-commit, either on Github or
via mail?

Best,
Albin

On 5/22/24 10:38 AM, Maciej Radziejewski wrote:
> Hello Albin,
>
> Thank you for your prompt reply! Indeed, adding -lmpfr -lgmp solved the
> problems. In addition I needed to enter
>
> export MACOSX_DEPLOYMENT_TARGET=$(sw_vers -productVersion)
>
> to avoid warnings that dylib (/usr/local/lib/libflint.dylib) was built
> for newer macOS version (12.0) than being linked (11.0). This may be a
> Homebrew-specific thing. I will report it there.
>
> It is great to have such easy access to the zeros of Riemann zeta. Thanks!
>
> I would suggest *two changes to the doc page*
> https://flintlib.org/doc/building.html
>
> *First*, the sentence " You may also have to pass the flags -lmpfr and
> -lgmp to the compiler" could be changed to:
>
> /For more advanced programs you may have to pass the flags/
> /[code snippet]/
> /-lmpfr -lgmp/
> /[/code snippet]/
> /to the compiler./
>
> Reason: these flags are actually not needed to compile test.c, and they
> should be made more visible. *Second*, I would start the "Quick start"
> with a note like this (I did not test MSYS2):
>
> /Many Linux flavours include package managers where Flint is ready to be
> installed automatically with all its dependencies. Package names and
> available Flint versions vary, so you need to search the packages list
> of your distribution. If you take that route, you will be missing the
> examples folder, but you can extract it from the full Flint download
> available here.  For Mac check out MacPorts or Homebrew, and for Windows
> MSYS2. Then see [#linking-and-running-code] below. If you wish to have
> more control, you can install Flint manually, as described here. /
> https://groups.google.com/d/msgid/flint-devel/f573b3ad-9b4f-4a1b-8f9b-55b3a636619cn%40googlegroups.com <https://groups.google.com/d/msgid/flint-devel/f573b3ad-9b4f-4a1b-8f9b-55b3a636619cn%40googlegroups.com> <https://groups.google.com/d/msgid/flint-devel/f573b3ad-9b4f-4a1b-8f9b-55b3a636619cn%40googlegroups.com?utm_medium=email&utm_source=footer <https://groups.google.com/d/msgid/flint-devel/f573b3ad-9b4f-4a1b-8f9b-55b3a636619cn%40googlegroups.com?utm_medium=email&utm_source=footer>>.
>
> --
>
> ---
> You received this message because you are subscribed to the Google
> Groups "flint-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to flint-devel...@googlegroups.com
> <mailto:flint-devel...@googlegroups.com>.
> To view this discussion on the web, visit
> https://groups.google.com/d/msgid/flint-devel/99aa230e-93fb-4533-b90d-57704cb2ebf1n%40googlegroups.com <https://groups.google.com/d/msgid/flint-devel/99aa230e-93fb-4533-b90d-57704cb2ebf1n%40googlegroups.com?utm_medium=email&utm_source=footer>.

Oscar Benjamin

unread,
May 22, 2024, 7:11:17 AMMay 22
to flint...@googlegroups.com, Maciej Radziejewski
Shouldn't pkgconfig show the necessary flags for your system?

$ cat .local/lib/pkgconfig/flint.pc
prefix=/home/oscar/current/active/python-flint/.local
includedir=${prefix}/include
libdir=${prefix}/lib

Name: flint
Description: Fast Library for Number Theory
Version: 3.1.0
Requires.private: gmp >= 6.2.1, mpfr >= 4.1.0
Libs: -L${libdir} -lflint
Libs.private: -lm
Cflags: -I${includedir}

$ PKG_CONFIG_PATH=$(pwd)/.local/lib/pkgconfig pkg-config --libs flint
-L/home/oscar/current/active/python-flint/.local/lib -lflint

If you have installed Flint system-wide then you do not need to set
PKG_CONFIG_PATH.

--
Oscar
> To unsubscribe from this group and stop receiving emails from it, send an email to flint-devel...@googlegroups.com.
> To view this discussion on the web, visit https://groups.google.com/d/msgid/flint-devel/856377cc-d7e1-43ce-8888-4511fec76201%40gmail.com.
Reply all
Reply to author
Forward
0 new messages