[getdns-api] Creating programs outside the src/example hierarchy

Paul Hoffman paul.hoffman at vpnc.org
Thu May 22 18:32:37 MST 2014


Greetings again. I'm not sure why I am having the following problem. I need to be creating standalone programs without being in src/example, and I'm clearly having some linking problem. This is running under Xubuntu 1404. I prepare the box with:

sudo apt-get install libevent-dev libidn11-dev libldns-dev libunbound-dev unbound-anchor
wget -O getdns-main.tgz https://github.com/getdnsapi/getdns/archive/v0.1.1.tar.gz
cd ~
tar -xzf getdns-main.tgz && cd ~/getdns-0.1.1/
./configure --with-libevent && make && sudo make install
sudo mkdir /etc/unbound
sudo unbound-anchor -a "/etc/unbound/getdns-root.key"

All that runs fine.

cd ~ && mkdir foo && cd foo
cp ~/getdns-0.1.1/src/example/example-simple-answers.c .
cp ~/getdns-0.1.1/src/example/getdns_libevent.h .
cp ~/getdns-0.1.1/libtool .

gcc works fine:

gcc -g -O2 -D_XOPEN_SOURCE=501 -Wall -I. -I/usr/local/include -std=c99 -c example-simple-answers.c -o example-simple-answers.o

libtool reports no errors:

./libtool --tag=CC --mode=link gcc -g -O2 -D_XOPEN_SOURCE=501 -Wall -I. -I/usr/local/include -std=c99 -L/usr/local/lib -lgetdns -lgetdns_ext_event -lunbound -lidn -lldns -o example-simple-answers example-simple-answers.o

libtool: link: gcc -g -O2 -D_XOPEN_SOURCE=501 -Wall -I. -I/usr/local/include -std=c99 -o example-simple-answers example-simple-answers.o  -L/usr/local/lib /usr/local/lib/libgetdns_ext_event.so /usr/local/lib/libgetdns.so -levent_core -lunbound -lidn -lldns

However:

# ./example-simple-answers
./example-simple-answers: error while loading shared libraries: libgetdns_ext_event-0.1.1.so.0: cannot open shared object file: No such file or directory

/usr/local/lib seems to have all the right stuff:

# dir /usr/local/lib
total 1204
drwxr-xr-x  4 root root    4096 May 22 18:03 .
drwxr-xr-x 10 root root    4096 Apr 16 11:26 ..
lrwxrwxrwx  1 root root      24 May 22 18:03 libgetdns-0.1.1.so.0 -> libgetdns-0.1.1.so.0.0.0
-rwxr-xr-x  1 root root  400495 May 22 18:03 libgetdns-0.1.1.so.0.0.0
-rw-r--r--  1 root root  761534 May 22 18:03 libgetdns.a
lrwxrwxrwx  1 root root      34 May 22 18:03 libgetdns_ext_event-0.1.1.so.0 -> libgetdns_ext_event-0.1.1.so.0.0.0
-rwxr-xr-x  1 root root   23194 May 22 18:03 libgetdns_ext_event-0.1.1.so.0.0.0
-rw-r--r--  1 root root   20388 May 22 18:03 libgetdns_ext_event.a
-rw-r--r--  1 root root    1083 May 22 18:03 libgetdns_ext_event.la
lrwxrwxrwx  1 root root      34 May 22 18:03 libgetdns_ext_event.so -> libgetdns_ext_event-0.1.1.so.0.0.0
-rw-r--r--  1 root root     972 May 22 18:03 libgetdns.la
lrwxrwxrwx  1 root root      24 May 22 18:03 libgetdns.so -> libgetdns-0.1.1.so.0.0.0
drwxrwsr-x  4 root staff   4096 Apr 16 11:29 python2.7
drwxrwsr-x  3 root staff   4096 Apr 16 11:26 python3.4

I'm fearing that the "-L. -L.. -L$(srcdir)/../" in the Makefile in src/example is required, and that libgetdns_ext_event.so is actually being found in src/, not /usr/local/lib. If that's the case, what recipe do I need for my call to libtool to make me able to create programs without being in src/example?

--Paul Hoffman


More information about the getdns-api mailing list