mersenneforum.org

mersenneforum.org (https://www.mersenneforum.org/index.php)
-   Programming (https://www.mersenneforum.org/forumdisplay.php?f=29)
-   -   Porting pari/gp routines into a C program?? (https://www.mersenneforum.org/showthread.php?t=17343)

EdH 2012-10-29 02:46

Thanks frmky,

I must have something else wrong. Both my IDE and command line give me the same trouble:

With pari_init(1000000000,2); or smaller:
[code]
[user@comp pariTest]$ ./ptest
a = 11
b = 17

*** the PARI stack overflows !
current stack size: 100000000 (95.367 Mbytes)
[hint] you can increase GP stack with allocatemem()

*** Error in the PARI system. End of program.
[/code]With pari_init(10000000000,2);:
[code]
[user@comp pariTest]$ ./ptest
a = 11
b = 17

*** segmentation fault: bug in PARI or calling program.
*** Error in the PARI system. End of program.
[/code]Must be a flaw in my system.:sad:

Off to try another system...

CRGreathouse 2012-10-29 03:52

The test program works on my system as well so it must be something with yours...

EdH 2012-10-29 13:25

There's a minor printing issue with the first machine, but the second one is frustrating. The second one, is my main system and I totally removed/reinstalled from scratch, both pari and gp2c.

machine math06 (Ubuntu 32-bit, repository versions of pari and gp2c):
[code]
math06@math06:~/Mathwork/pari$ whereis pari
pari: /usr/lib/pari /usr/include/pari /usr/share/pari /usr/share/man/man1/pari.1.gz
math06@math06:~/Mathwork/pari$ whereis gp2c
gp2c: /usr/bin/gp2c /usr/share/gp2c /usr/share/man/man1/gp2c.1.gz
math06@math06:~/Mathwork/pari$ gcc -o ptest -g -O3 -Wall -fomit-frame-pointer -fno-strict-aliasing -fPIC -I"/usr/include" pariTest.gp.c -lc -lm -L/usr/lib -lpari
pariTest.gp.c: In function 'pTest':
pariTest.gp.c:28:7: warning: implicit declaration of function 'pari_printf'
pariTest.gp.c: In function 'main':
pariTest.gp.c:43:8: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result
pariTest.gp.c:45:8: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result
/tmp/ccgpmm0C.o: In function `pTest':
/home/math06/Mathwork/pari/pariTest.gp.c:28: undefined reference to `pari_printf'[B]***[/B]
collect2: ld returned 1 exit status
math06@math06:~/Mathwork/pari$ gcc -o ptest -g -O3 -Wall -fomit-frame-pointer -fno-strict-aliasing -fPIC -I"/usr/include" pariTest.gp.c -lc -lm -L/usr/lib -lpari
pariTest.gp.c: In function 'main':
pariTest.gp.c:43:8: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result
pariTest.gp.c:45:8: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result
math06@math06:~/Mathwork/pari$ ./ptest
a = 11
b = 17
e is %Ps
e is %Ps
e is %Ps
e is %Ps
e is %Ps
e is %Ps
e is %Ps
[/code][B]***[/B]I had to change pari_print() to pariprint().

machine comp (Fedora 64-bit, manual installation of pari and gp2c):
[code]
[user@comp examples]$ whereis pari
pari: /usr/local/lib/pari
[user@comp examples]$ whereis libpari
libpari: /usr/local/lib/libpari.so
[user@comp examples]$ whereis libpari-gmp.so.3
libpari-gmp.so: /usr/local/lib/libpari-gmp.so.3
[user@comp examples]$ gcc -o ptest -g -O3 -Wall -fomit-frame-pointer -fno-strict-aliasing -fPIC -I"/usr/local/lib" ptest.gp.c -lc -lm -L/usr/local/lib -lpari
[user@comp examples]$ ./ptest
./ptest: error while loading shared libraries: libpari-gmp.so.3: cannot open shared object file: No such file or directory
[user@comp examples]$ gcc -o ptest -g -O3 -Wall -fomit-frame-pointer -fno-strict-aliasing -fPIC -I"/usr/local/lib" ptest.gp.c -lc -lm -L"/usr/local/lib" -lpari
[user@comp examples]$ ./ptest
./ptest: error while loading shared libraries: libpari-gmp.so.3: cannot open shared object file: No such file or directory
[/code]:sad:

frmky 2012-10-29 16:46

The problem on the 64-bit Fedora computer sounds like an ldconfig issue. See [url]http://www.brunolinux.com/02-The_Terminal/ldconfig.html[/url].

jcrombie 2012-10-29 17:02

[QUOTE=frmky;316355]The problem on the 64-bit Fedora computer sounds like an ldconfig issue. See [URL]http://www.brunolinux.com/02-The_Terminal/ldconfig.html[/URL].[/QUOTE]

That was what I was thinking too.

I would try just typing: "sudo ldconfig" first without editing any system files and see if that works.

Also, you can type: "ldd ptest" to check if all shared libraries are going to be found at runtime without having to run the program.

EdH 2012-10-29 19:14

Thanks guys! That did the trick, although it was very convoluted on this Fedora system. sudo anything doesn't work and you can't do any GUI type file management or text editing as the superuser. Also the ld.so.conf file only contains a single line to include all the files in the ld.so.conf.d directory. So, instead of trying to edit it, I wrote usr-local-lib.conf elsewhere (as user) and cp'd that into the ld.so.conf.d directory using superuser.

Prior to usr-local-lib.conf creation:
[code]
[user@comp examples]$ ldd ptest
linux-vdso.so.1 => (0x00007fff0f95b000)
libc.so.6 => /lib64/libc.so.6 (0x00000036e1200000)
libm.so.6 => /lib64/libm.so.6 (0x00000036e2200000)
/lib64/ld-linux-x86-64.so.2 (0x00000036e0e00000)
libpari-gmp.so.3 => not found
[/code]After usr-local-lib.conf creation:
[code]
[user@comp examples]$ ldd ptest
linux-vdso.so.1 => (0x00007fff005cb000)
libc.so.6 => /lib64/libc.so.6 (0x00000036e1200000)
libm.so.6 => /lib64/libm.so.6 (0x00000036e2200000)
libpari-gmp.so.3 => /usr/local/lib/libpari-gmp.so.3 (0x00007f64ded57000)
/lib64/ld-linux-x86-64.so.2 (0x00000036e0e00000)
libgmp.so.3 => /usr/lib64/libgmp.so.3 (0x00000036e3200000)
[user@comp examples]$ ./ptest
a = 11
b = 17
e is 11
e is 12
e is 13
e is 14
e is 15
e is 16
e is 17
[/code]BTW, ldconfig ran under superuser, but made no difference until I manually added the file to the directory.

Now, I'll see what happens when I modify it more into what I'm after and eventually see if I can get it all working in my IDE.

Thanks much, everyone...

EdH 2012-10-30 03:41

[QUOTE=frmky;316304]I doubt it. The idea of gp2c-run is to combine the speed of the c compiled function with the ease of use of the gp calculator.[/QUOTE]
They do indeed seem to run at extremely close to the same speed.

I still haven't figured out how to compile within my IDE. But, I'm going to study makefiles for a while, anyway, and set the IDE aside for these things...

Thanks for all...


All times are UTC. The time now is 06:26.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.