On Sun, 14 Feb 2016, Salman Khan wrote:
I'm trying to compile a test program from one of the libgretl
examples on 64bit Linux Mint 17.3. My goal is to call gretl
routines from C.
I think configure went ok (linked it to lapack: sudo
LAPACK_LIBS=/usr/lib/liblapack.a ./configure). Then make, make
install and sudo ldconfig.
I run the following command (and other countless variations) to
compile:gcc -o gretl_test -L/usr/local/lib/libgretl-1.0.so
`pkg-config --cflags --libs glib-2.0` gretl_test.c
However, I get the following errors:/tmp/ccCyYTcx.o: In function
`main':gretl_test.c:(.text+0x22): undefined reference to
`libgretl_init'gretl_test.c:(.text+0x31): undefined reference to
`gretl_print_new'gretl_test.c:(.text+0x3a): undefined reference to
`datainfo_new'gretl_test.c:(.text+0x51): undefined reference to
`gretl_read_native_data'gretl_test.c:(.text+0x83): undefined
reference to `pprintf'gretl_test.c:(.text+0x94): undefined
reference to `errmsg'gretl_test.c:(.text+0xb0): undefined
reference to `pprintf'gretl_test.c:(.text+0xc5): undefined
reference to `print_smpl'gretl_test.c:(.text+0xd8): undefined
reference to `varlist'gretl_test.c:(.text+0xe4): undefined
reference to `destroy_dataset'gretl_test.c:(.text+0xf0): undefined
reference to `gretl_print_destroy'gretl_test.c:(.text+0xf5):
undefined reference to `libgretl_cleanup'
I'm a relatively new convert to linux as well as gretl, is there
something obvious that I'm missing? Thank you.
To ensure the correct libraries are linked in, you should use
gretl's pkgconfig file. There's an example Makefile in the "extra"
subdir of the gretl sources. Abstracting a little from the
specifics there, at minimum you need:
CFLAGS = $(shell pkg-config --cflags gretl)
LDFLAGS = $(shell pkg-config --libs gretl)
Allin Cottrell