| Sac-Epee Jean-Marc on Wed, 23 Jun 2010 22:28:59 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
| gp2c howto |
Hi everybody,
I try to use gp2c... unsuccessfully for the moment.
1. For example, in a file named test.gp, I wrote the line
l=polroots(x^2-3*x+1); print(l);
2. In a console, I wrote
gp2c test.gp > test.c
The file test.c is :
#include <pari/pari.h>
/*
GP;install("init_test","vp","init_test","./test.gp.so");
*/
void init_test(long prec);
/*End of prototype*/
static GEN l;
static GEN x;
/*End of global vars*/
void
init_test(long prec) /* void */
{
l = pol_x[fetch_user_var("l")];
x = pol_x[fetch_user_var("x")];
l = roots0(gaddgs(gsub(gsqr(x), gmulsg(3, x)), 1), 0, prec);
pariprintf("%Z\n", l);
return;
}
3. I run the usual Makefile (see below), and obtained :
[jmse@hal Pari]$ make
/usr/bin/gcc -c -O3 -Wall -fno-strict-aliasing -fomit-frame-pointer -O3
-Wall -fno-strict-aliasing -fomit-frame-pointer -I.
-I/usr/local/include test.c
/usr/bin/gcc -o test-dyn -O3 -Wall -fno-strict-aliasing
-fomit-frame-pointer -Wl,--export-dynamic test.o
-Wl,-rpath,/usr/local/lib -ldl -lm -L/usr/local/lib -lpari
/usr/lib/gcc/i586-manbo-linux-gnu/4.3.2/../../../crt1.o: In function
`_start':
/home/qateam/rpm/BUILD/glibc-2.9/csu/../sysdeps/i386/elf/start.S:115:
undefined reference to `main'
collect2: ld a retourné 1 code d'état d'exécution make: *** [test-dyn] Erreur 1 Actually, the file test.c has no main procedure...This the Makefile found in /usr/local/pari-2.3.4/examples, which run well with the file extgcd.c (in my Makefile, the line TARGET = extgcd is replaced with TARGET = test).
# Generic Makefile for PARI programs -- i686 running linux (ix86 kernel) 32-bit version
#
# This file was created by Configure. Any change made to it will be
# lost when Configure is run.
#
# make all will create
# extgcd-dyn (linked dynamically with libpari)
# extgcd-sta (linked statically)
# libextgcd.so (to be used by "install" under GP)
#
# Under GP: install("extgcd", "GG&&", "gcdex", "./libextgcd.so") enables
# you to subsequently use gcdex to call extgcd (see the reference manual).
#
# change this TARGET to compile your own programs
TARGET = test
SHELL = /bin/sh
DBGFLAGS = -g -Wall -O3 -Wall -fno-strict-aliasing -fomit-frame-pointer
CFLAGS = -O3 -Wall -fno-strict-aliasing -fomit-frame-pointer -O3
-Wall -fno-strict-aliasing -fomit-frame-pointer
#CFLAGS = $(DBGFLAGS) # Various linkers use different flags to force static compilation. Choose # the one which is relevant for your installation. # # Solaris ld (global) #STATIC = -dn # Solaris ld (toggle: no shared object accepted until -B dynamic is seen #STATIC = -B static # gcc #STATIC = -static CC = /usr/bin/gcc CPPFLAGS = -I. -I/usr/local/include LD = /usr/bin/gccLDFLAGS = -O3 -Wall -fno-strict-aliasing -fomit-frame-pointer -Wl,--export-dynamic
MODLD = /usr/bin/gcc
MODLDFLAGS = -shared $(CFLAGS) $(DLCFLAGS) -Wl,-shared
EXTRAMODLDFLAGS = -lc -ldl -lm -L/usr/local/lib -lpari
EXTRALIBS =
RUNPTH = -Wl,-rpath,/usr/local/lib
DLCFLAGS =
LIBS = -ldl -lm -L/usr/local/lib -lpari
RM = rm -f
OBJS = $(TARGET).o
DYN = lib$(TARGET).so
ALL = $(TARGET)-sta $(TARGET)-dyn $(DYN)
dft: $(TARGET)-dyn
all: $(ALL)
sta: $(TARGET)-sta
dyn: $(TARGET)-dyn
dynlib: $(DYN)
$(DYN): $(OBJS)
$(MODLD) -o $@ $(MODLDFLAGS) $(OBJS) $(EXTRAMODLDFLAGS)
$(TARGET)-sta: $(OBJS)
$(LD) -o $@ $(LDFLAGS) $< $(EXTRALIBS) $(STATIC) $(LIBS)
$(TARGET)-dyn: $(OBJS)
$(LD) -o $@ $(LDFLAGS) $< $(RUNPTH) $(LIBS)
%.o: %.c
$(CC) -c $(CFLAGS) $(CPPFLAGS) $(DLCFLAGS) $<
clean:
-$(RM) *.o $(ALL)
For you, what is the problem in my process ?
Thanks for advance,
Jean-Marc
--
Jean-Marc Sac-Epée, Ingénieur de Recherches en Calcul Scientifique,
Laboratoire de Mathématiques, UMR 7122, Université de Metz,
Tél 03 87 54 72 69 Fax 03 87 31 52 73
http://www.math.univ-metz.fr/~jmse mail: jmse@math.univ-metz.fr