Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

static compile of libcurl apps linux C (missing library)

//to-long-didnt-read -> missing lgssapi_krb5 library and can't seem to find it

i am having trouble statically linking libcurl using one of they're test applications.

ive read forums and someone said issue the "curl-config --libs" command and include all those libraries, but the command only returns

~/Desktop# curl-config --libs
-lcurl

while theirs returns

[root@zabbix ~]# curl-config --libs
-L/usr/kerberos/lib -lcurl -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lresolv -ldl -lidn -lssl -lcrypto -lz 

i've also read this post

Static linking libcurl using c

and my output is

~/Desktop# ldd /usr/lib/libcurl.so
        linux-gate.so.1 =>  (0xb78be000)
        libidn.so.11 => /usr/lib/libidn.so.11 (0xb7837000)
        liblber-2.4.so.2 => /usr/lib/liblber-2.4.so.2 (0xb782a000)
        libldap_r-2.4.so.2 => /usr/lib/libldap_r-2.4.so.2 (0xb77e2000)
        librt.so.1 => /lib/tls/i686/cmov/librt.so.1 (0xb77d9000)
        libgssapi_krb5.so.2 => /usr/lib/libgssapi_krb5.so.2 (0xb77aa000)
        libz.so.1 => /lib/libz.so.1 (0xb7795000)
        libgnutls.so.26 => /usr/lib/libgnutls.so.26 (0xb76fa000)
        libgcrypt.so.11 => /lib/libgcrypt.so.11 (0xb7686000)
        libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb752c000)
        libresolv.so.2 => /lib/tls/i686/cmov/libresolv.so.2 (0xb7518000)
        libsasl2.so.2 => /usr/lib/libsasl2.so.2 (0xb7500000)
        libpthread.so.0 => /lib/tls/i686/cmov/libpthread.so.0 (0xb74e7000)
        /lib/ld-linux.so.2 (0xb78bf000)
        libkrb5.so.3 => /usr/lib/libkrb5.so.3 (0xb7436000)
        libk5crypto.so.3 => /usr/lib/libk5crypto.so.3 (0xb7411000)
        libcom_err.so.2 => /lib/libcom_err.so.2 (0xb740d000)
        libkrb5support.so.0 => /usr/lib/libkrb5support.so.0 (0xb7405000)
        libdl.so.2 => /lib/tls/i686/cmov/libdl.so.2 (0xb7401000)
        libkeyutils.so.1 => /lib/libkeyutils.so.1 (0xb73fd000)
        libtasn1.so.3 => /usr/lib/libtasn1.so.3 (0xb73eb000)
        libgpg-error.so.0 => /lib/libgpg-error.so.0 (0xb73e6000)

and when i try to compile using

~/Desktop# gcc -static test.c -o down -lcurl -lidn -llber -lldap -lrt -lgssapi_krb5 -lgssapi_krb5 -lz -lgnutls -lgcrypt

i get

/usr/bin/ld: cannot find -lgssapi_krb5
collect2: ld returned 1 exit status

i've tried searching around for this library, but i can't seem to find it through google searches. i've also tried to apt-get cache search it but it returned no results. i am running Ubuntu and any help is highly appreciated.

like image 296
randy newfield Avatar asked Mar 10 '12 18:03

randy newfield


1 Answers

found a work around that works.

$ wget http://curl.haxx.se/download/curl-7.24.0.tar.lzma
$ tar xf curl-7.24.0.tar.lzma
$ cd curl-7.24.0
$ ./configure --disable-shared --enable-static --prefix=/tmp/curl --disable-ldap --disable-sspi
$ make && make install
$ cat << EOF > a.c
#include <curl/curl.h>
int main() {
printf("%s\n", curl_version());
return 0;
}
EOF
$ gcc a.c -static $(/tmp/curl/bin/curl-config --static-libs --cflags) -ldl
$ file a.out
a.out: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, for GNU/Linux 2.6.15, not stripped
$ ./a.out
libcurl/7.24.0 OpenSSL/1.0.0e zlib/1.2.3.4 libidn/1.22
like image 53
randy newfield Avatar answered Oct 06 '22 02:10

randy newfield