Thread: unresolved externals when linking app with libpq 8.03
Hi everybody, I have got some problems with linking my postgres application on Linux Environment: Fedora core 4, PostgreSQL 8.0.3 I was able to link my postgresql apps successfully when I was using PostgreSQL version 8.0.1 or earlier. Now (v. 8.0.3) the linker tells me there is many unresolved externals. I believe it's due to new version of libpq library (which has been announced with pgsql ver. 8.0.2). But I can't realize which additional libraries I should put to linker to get success. There are examples of unresoved symbols when using -lpq option to linker: lib/sql/postgresql/ver803/lib/linux/libpq.a(fe-misc.o)(.text+0x68a): In function 'pqSocketCheck': /usr/src/build/565044-i386/BUILD/postgresql-8.0.3/src/interfaces/libpq/fe-misc.c :974: undefined reference to `SSL_pending' undefined reference to `PEM_read_DHparams' undefined reference to `DH_size' undefined reference to `PEM_read_bio_DHparams' undefined reference to `BIO_free' undefined reference to `SSL_read' undefined reference to `X509_NAME_oneline' undefined reference to `CRYPTO_num_locks' undefined reference to `krb5_cc_get_principal' undefined reference to `error_message' (66 unresolved symbols in total) when I added -lkrb5 (kerberos library as I guess) to linker some unresolved symbols vanishes whereas the others appeared, for example lib/sql/postgresql/ver803/lib/linux/libkrb5.a(init_ctx.o)(.text+0x221): In function `get_profile_etype_list':: undefined reference to `krb5_string_to_enctype' (114 unresolved externals in total) adding -lkrb5support to linking doesn't help So, my question is which libraries I shoud add to the linker command line and in which sequence to get my app linked successfully. I couldn't find any examples in Web till now. Thanks in advance. -- Regards Jarek Lubczynski There are 10 kinds of people: Those who understand binary and those who don't
eljot <eljot@elkomtech.com.pl> writes: > I was able to link my postgresql apps successfully when I was using > PostgreSQL version 8.0.1 or earlier. Now (v. 8.0.3) the linker tells me > there is many unresolved externals. > :974: undefined reference to `SSL_pending' > undefined reference to `PEM_read_DHparams' > undefined reference to `DH_size' > undefined reference to `PEM_read_bio_DHparams' > undefined reference to `BIO_free' > undefined reference to `SSL_read' > undefined reference to `X509_NAME_oneline' > undefined reference to `CRYPTO_num_locks' > undefined reference to `krb5_cc_get_principal' > undefined reference to `error_message' Apparently you've configured the new Postgres build with SSL and Kerberos support, which you didn't have in your 8.0.1 build. The path of least resistance might be to go back to the old configuration. Alternatively, look at psql with ldd to find out what libraries it depends on. regards, tom lane
Tom Lane wrote: >eljot <eljot@elkomtech.com.pl> writes: > > >>I was able to link my postgresql apps successfully when I was using >>PostgreSQL version 8.0.1 or earlier. Now (v. 8.0.3) the linker tells me >>there is many unresolved externals. >> >> >Apparently you've configured the new Postgres build with SSL and >Kerberos support, which you didn't have in your 8.0.1 build. > No, I didn't change anything. The only thing I did is I had copied the proper .h files and libpq.a file to specified directories on my development machine. I must compile my apps for various versions of postgres (and some other rdbms as well) in the same time, so I can't directly use c-interface files installed by postgresql itself. I didn't change my makefile at all. So I think the problem may be with compilation of files included in new version of libpq.a (PostgreSQL 8.0.3 from FC4). >[...] >Alternatively, look at psql with ldd to find out what libraries it >depends on. > > Thanks a lot, it was really helpful. If anybody is interested in this is a part of command for linker which has given me a success: -lpq -lpam -lssl -lcrypto -lkrb5 -lz -lreadline -ltermcap -lcrypt -lresolv -lnsl -ldl -lpthread -lgssapi_krb5 -lcom_err -lk5crypto -lkrb5support -lgcc_eh For postgresql 8.0.1 and earlier linking only with with -lpq was sufficient. The executable file growed fom 1.0MB (8.0.1) to 2.3MB (8.0.3) and I'm afraid it may not work without recompiling under other Linux distributions (I will test it's behaviour on FC3, RH9 & SUSE 9.3 soon) due to many additional shared libraries used. So I'd like to get rid of extra libs if it is possible of course, and still have no idea how to do this. Than's again for your help. > regards, tom lane > > > -- Regards Jarek Lubczynski There are 10 kinds of people: Those who understand binary and those who don't