FLINT 3: rational functions with fmpz_mpoly_q and C++ linking

82 views
Skip to first unread message

grea...@gmail.com

unread,
May 28, 2023, 8:37:25 PM5/28/23
to flint-devel
I've been using Nemo for multivariate rational functions, but I'm exploring moving back to C/C++. I just tried the latest github version of FLINT, which has the needed header fmpz_mpoly_q.h, previously part of Calcium. I was able write simple C programs with this. However, I'm not able to compile it under C++, even if I write

extern "C" {
#include "fmpz_mpoly_q.h"
}

This immediately triggers the g++ compiler to complain "error: template with C linkage". More lines of the error message is shown below. Is there a quick solution, or should I wait for the official FLINT 3 release?

In file included from /usr/include/c++/11/bits/stringfwd.h:40,
                 from /usr/include/c++/11/iosfwd:39,
                 from /usr/include/x86_64-linux-gnu/gmp.h:34,
                 from /home/username/flint2/local/include/flint/flint.h:28,
                 from /home/username/flint2/local/include/flint/fmpz_types.h:15,
                 from /home/username/flint2/local/include/flint/fmpz.h:21,
                 from /home/username/flint2/local/include/flint/fmpq.h:22,
                 from /home/username/flint2/local/include/flint/fmpz_mpoly_q.h:25,
                 from try.cpp:3:
/usr/include/c++/11/bits/memoryfwd.h:63:3: error: template with C linkage




grea...@gmail.com

unread,
May 28, 2023, 8:41:10 PM5/28/23
to flint-devel
More information: the same error appears if I don't use "extern C".

Fredrik Johansson

unread,
May 29, 2023, 3:54:03 AM5/29/23
to flint...@googlegroups.com
Could you share a minimal failing .cpp program?

The following works for me when compiling with g++ 11.3.0.

#include "fmpz_mpoly.h"
#include "fmpz_mpoly_q.h"

int main()
{
    fmpz_mpoly_q_t a;
    fmpz_mpoly_ctx_t ctx;

    fmpz_mpoly_ctx_init(ctx, 3, ORD_LEX);
    fmpz_mpoly_q_init(a, ctx);

    fmpz_mpoly_q_print_pretty(a, NULL, ctx);

    return 0;
}

Fredrik

--

---
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.
To view this discussion on the web, visit https://groups.google.com/d/msgid/flint-devel/cac4d44a-b158-4500-9060-caf81401ff5cn%40googlegroups.com.

grea...@gmail.com

unread,
May 29, 2023, 9:03:25 AM5/29/23
to flint-devel
What's funny is that if I comment out the first line of your code,
#include "fmpz_mpoly.h",

then it still compiles and runs without problems with gcc, but breaks under g++. The above line is exactly what's missing from my code that caused the error. (I'm using Ubuntu 22.04 and the gmp version from the distro repo.)
Reply all
Reply to author
Forward
0 new messages