Ah!!!

clang++ -lgmp -lgmpxx -o
./find_largest_left_truncatable_prime_in_a_given_base
./find_largest_left_truncatable_prime_in_a_given_base.cpp

Works!

Thanks!!!

On Wed, Jul 30, 2025 at 12:55 PM Ryan Carsten Schmidt
<[email protected]> wrote:
>
> On Jul 30, 2025, at 14:52, Kenneth Wolcott wrote:
>
>
> Hi;
>
>
> What do I need to add or modify to my clang++ compile command?
>
>
> I installed gmp via MacPorts:
>
>
> port installed | grep gmp | grep -v p5 | grep -v R | grep -v py
>
> gmp @6.3.0_0 (active)
>
>
> FYI you can just use "port installed gmp".
>
>
> When I try to compile a Rosetta Code task written in C++
>
>
> (https://rosettacode.org/wiki/Find_largest_left_truncatable_prime_in_a_given_base#C++)
>
>
> I get these error(s):
>
>
> clang++ -std=c++20 -lgmp -o
>
> ./find_largest_left_truncatable_prime_in_a_given_base
>
> ./find_largest_left_truncatable_prime_in_a_given_base.cpp
>
>
> Undefined symbols for architecture arm64:
>
> "operator<<(std::__1::basic_ostream<char,
>
> std::__1::char_traits<char>>&, __mpz_struct const*)", referenced from:
>
>     std::__1::basic_ostream<char, std::__1::char_traits<char>>&
>
> operator<<<__mpz_struct [1], __mpz_struct
>
> [1]>(std::__1::basic_ostream<char, std::__1::char_traits<char>>&,
>
> __gmp_expr<__mpz_struct [1], __mpz_struct [1]> const&) in
>
> find_largest_left_truncatable_prime_in_a_given_base-ef7644.o
>
> ld: symbol(s) not found for architecture arm64
>
> clang++: error: linker command failed with exit code 1 (use -v to see
>
> invocation)
>
>
> According to
>
> https://stackoverflow.com/questions/14164535/c-gmp-library-ostream-operator-compiles-but-doesnt-link
>
> add -lgmpxx; that worked for me.
>
>
> On Jul 30, 2025, at 14:07, Richard L. Hamilton wrote:
>
>
> You may need -lc++
>
>
> You never need to add -lc++, as long as you use a C++ compiler like clang++ 
> to do the linking, which Ken did.
>

Reply via email to