I would like to print version of libpari library from c program
#include <gmp.h>
#include <mpfr.h>
#include <mpc.h>
#include<pari/pari.h>
int main(void){
gmp_printf ("MPFR library: %-12s\nMPFR header: %s (based on %d.%d.%d)\n",
mpfr_get_version (), MPFR_VERSION_STRING, MPFR_VERSION_MAJOR,
MPFR_VERSION_MINOR, MPFR_VERSION_PATCHLEVEL);
gmp_printf (" GMP-%s \n ", gmp_version );
mpfr_printf(" MPC-%s \nMPFR-%s \n GMP-%s \n", MPC_VERSION_STRING, mpfr_version, gmp_version );
gmp_printf("pari_version = %s\n", GENtostr(pari_version())); // paricfg_version_code);
return 0;
Program compiles but
gcc g.c -lpari -lmpc -lmpfr -lgmp -Wall
a@zalman:~/Dokumenty/gmp$ ./a.out
MPFR library: 4.1.0
MPFR header: 4.1.0 (based on 4.1.0)
GMP-6.2.1
MPC-1.2.0
MPFR-4.1.0
GMP-6.2.1
Memory protection violation
I have tried also
pari_printf("pari_version = %Ps\n", GENtostr(pari_version())); // paricfg_version_code);
pari_flush();
I have googled it and search the manual. How can I do it ?
pari_init()call; the functionpari_version()needs the pari stack to create its return value there...It should work in your main program, the one that actually uses the pari library and includes a
pari_init()first. You might want to print the result as(M, m, p stand for Major version number, minor version number and patchlevel)
The second attempt using
pari_printf()can't work for the same reason and also because you shouldn't then useGENtostr()because it converts theGENto achar*and the%Psconstruct expects aGENargument.If you really want it to work without the pari stack, you can adapt the solution in your answer by "decoding" the version code as follows