Hmmm... I cd'ed into the extras folder and tried compiling the three examples there with the default makefile.I still get errors:

cc -g -O2 -Wall -I/usr/local/include -I/usr/include/libxml2 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include   -DPREFIX=\"/usr/local\"  -fopenmp -L/usr/local/lib -lgretl-1.0 -lm -lxml2 -lfftw3 -lglib-2.0    simple_client.c   -o simple_client
/tmp/ccUP9gBA.o: In function `main':
Downloads/gretl-2016a/extra/simple_client.c:52: undefined reference to `libgretl_init'
Downloads/gretl-2016a/extra/simple_client.c:54: undefined reference to `gretl_print_new'
Downloads/gretl-2016a/extra/simple_client.c:62: undefined reference to `create_new_dataset'
Downloads/gretl-2016a/extra/simple_client.c:90: undefined reference to `gretl_list_new'
Downloads/gretl-2016a/extra/simple_client.c:97: undefined reference to `gretl_model_new'
Downloads/gretl-2016a/extra/simple_client.c:99: undefined reference to `lsq'
Downloads/gretl-2016a/extra/simple_client.c:116: undefined reference to `printmodel'
Downloads/gretl-2016a/extra/simple_client.c:120: undefined reference to `gretl_model_free'
Downloads/gretl-2016a/extra/simple_client.c:122: undefined reference to `destroy_dataset'
Downloads/gretl-2016a/extra/simple_client.c:123: undefined reference to `gretl_print_destroy'
Downloads/gretl-2016a/extra/simple_client.c:125: undefined reference to `libgretl_cleanup'
Downloads/gretl-2016a/extra/simple_client.c:108: undefined reference to `gretl_errmsg_get'
collect2: error: ld returned 1 exit status
make: *** [simple_client] Error 1



On Sunday, February 14, 2016 5:31 PM, Allin Cottrell <cottrell@wfu.edu> wrote:


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