You are not logged in.
Hello! I apologize in advance if this isn't the correct forum to address this issue.
A little background of what I'm trying to do: I'm creating a simple C program using the curl library and I want it to be static (I don't want to discuss wheter this is a good or a bad thing, nor accept alternatives).
Anyway, since Arch doesn't build static libraries by default, I've had to rebuild all of the curl dependencies using ABS and adding 'staticlibs' to their PKGBUILD. Okay, I did this with all the packages (openssl, zlib, etc.) and it worked just fine. However, the only dependency left to do it is krb5. I did the exact same thing I was doing, but this time Arch isn't building the static libraries and I don't know if I'm missing some parameter in the ./configure script, doing something wrong on GCC or what else!
When I try to compile my program using GCC, this is what I get:
$ gcc64 -static program.c -ljson-c $(curl-config --static-libs) $(krb5-config --libs) -o program
/usr/bin/ld: cannot find -lgssapi_krb5
/usr/bin/ld: cannot find -lkrb5
/usr/bin/ld: cannot find -lk5crypto
/usr/bin/ld: cannot find -lcom_err
/usr/bin/ld: cannot find -lkrb5
/usr/bin/ld: cannot find -lk5crypto
/usr/bin/ld: cannot find -lcom_err
AFAIK, all of these dependencies are from krb5. Also, here's my modified PKGBUILD for krb5 1.13.2-1 (which doesn't build the static libraries):
# $Id: PKGBUILD 242144 2015-07-12 16:38:48Z bpiotrowski $
# Maintainer:
pkgname=krb5
pkgver=1.13.2
pkgrel=1
pkgdesc="The Kerberos network authentication system"
arch=('i686' 'x86_64')
url="http://web.mit.edu/kerberos/"
license=('custom')
depends=('e2fsprogs' 'libldap' 'keyutils')
makedepends=('perl')
backup=('etc/krb5.conf' 'var/lib/krb5kdc/kdc.conf')
options=('!emptydirs' 'staticlibs')
source=(http://web.mit.edu/kerberos/dist/krb5/${pkgver%.*}/${pkgname}-${pkgver}-signed.tar
krb5-config_LDFLAGS.patch
krb5-kadmind.service
krb5-kdc.service
krb5-kpropd.service
krb5-kpropd@.service
krb5-kpropd.socket)
sha1sums=('ea824badb2d600745dcbbdfe58ccb84cba8509f0'
'f125824ed37f31e6fd2fdb6a437be8ff1c3700ab'
'59bbc7e686cbb4bcefddf0f134d928d7bd5e7722'
'2ef2476a8673b3b702e829d8f451c839c2273b02'
'74d66aefd291f22dd80799f0437cc03d83083ed5'
'6787c6ce2783b3f980c423e2dd4abf5236af670b'
'f3677d30dbbd7106c581379c2c6ebb1bf7738912')
prepare() {
tar -xf ${pkgname}-${pkgver}.tar.gz
cd ${pkgname}-${pkgver}
# cf https://bugs.gentoo.org/show_bug.cgi?id=448778
patch -p1 -i "${srcdir}"/krb5-config_LDFLAGS.patch
# FS#25384
sed -i "/KRB5ROOT=/s/\/local//" src/util/ac_check_krb5.m4
}
build() {
cd ${pkgname}-${pkgver}/src
export CFLAGS+=" -fPIC -fno-strict-aliasing -fstack-protector-all"
export CPPFLAGS+=" -I/usr/include/et"
./configure --prefix=/usr \
--sbindir=/usr/bin \
--sysconfdir=/etc \
--localstatedir=/var/lib \
--enable-shared \
--with-system-et \
--with-system-ss \
--disable-rpath \
--without-tcl \
--enable-dns-for-realm \
--with-ldap \
--without-system-verto
make
}
package() {
cd ${pkgname}-${pkgver}/src
make DESTDIR="${pkgdir}" EXAMPLEDIR=/usr/share/doc/${pkgname}/examples install
# Fix FS#29889
install -m 644 plugins/kdb/ldap/libkdb_ldap/kerberos.{ldif,schema} "${pkgdir}"/usr/share/doc/${pkgname}/examples
# Sample KDC config file
install -dm 755 "${pkgdir}"/var/lib/krb5kdc
install -pm 644 config-files/kdc.conf "${pkgdir}"/var/lib/krb5kdc/kdc.conf
# Default configuration file
install -dm 755 "${pkgdir}"/etc
install -pm 644 config-files/krb5.conf "${pkgdir}"/etc/krb5.conf
install -dm 755 "${pkgdir}"/usr/share/aclocal
install -m 644 util/ac_check_krb5.m4 "${pkgdir}"/usr/share/aclocal
install -Dm644 "${srcdir}"/${pkgname}-${pkgver}/NOTICE "${pkgdir}"/usr/share/licenses/${pkgname}/LICENSE
# systemd stuff
install -dm 755 "${pkgdir}"/usr/lib/systemd/system
install -m 644 ../../krb5-{kadmind.service,kdc.service,kpropd.service,kpropd@.service,kpropd.socket} \
"${pkgdir}"/usr/lib/systemd/system
}
Any help is appreciated. Thank you.
Last edited by guihkx (2015-11-07 02:25:41)
Offline
Try this PKGBUILD:
pkgname=krb5
pkgver=1.13.2
pkgrel=1
pkgdesc="The Kerberos network authentication system"
arch=('i686' 'x86_64')
url="http://web.mit.edu/kerberos/"
license=('custom')
depends=('e2fsprogs' 'libldap' 'keyutils')
makedepends=('perl' 'yasm')
backup=('etc/krb5.conf' 'var/lib/krb5kdc/kdc.conf')
options=('!emptydirs' 'staticlibs')
source=(http://web.mit.edu/kerberos/dist/krb5/${pkgver%.*}/${pkgname}-${pkgver}-signed.tar
krb5-config_LDFLAGS.patch
krb5-kadmind.service
krb5-kdc.service
krb5-kpropd.service
krb5-kpropd@.service
krb5-kpropd.socket)
sha1sums=('ea824badb2d600745dcbbdfe58ccb84cba8509f0'
'f125824ed37f31e6fd2fdb6a437be8ff1c3700ab'
'59bbc7e686cbb4bcefddf0f134d928d7bd5e7722'
'2ef2476a8673b3b702e829d8f451c839c2273b02'
'74d66aefd291f22dd80799f0437cc03d83083ed5'
'6787c6ce2783b3f980c423e2dd4abf5236af670b'
'f3677d30dbbd7106c581379c2c6ebb1bf7738912')
prepare() {
tar -xf ${pkgname}-${pkgver}.tar.gz
cd ${pkgname}-${pkgver}
# cf https://bugs.gentoo.org/show_bug.cgi?id=448778
patch -p1 -i "${srcdir}"/krb5-config_LDFLAGS.patch
# FS#25384
sed -i "/KRB5ROOT=/s/\/local//" src/util/ac_check_krb5.m4
}
build() {
cd ${pkgname}-${pkgver}/src
export CFLAGS+=" -fPIC -fno-strict-aliasing -fstack-protector-all"
./configure --prefix=/usr \
--sbindir=/usr/bin \
--sysconfdir=/etc \
--localstatedir=/var/lib \
--disable-shared \
--enable-static \
--disable-rpath \
--without-tcl \
--enable-dns-for-realm \
--with-ldap \
--without-system-verto
make AS='yasm -D__linux__ -f elf -m amd64' VERTO_LIBS=' -lverto -lm'
}
package() {
cd ${pkgname}-${pkgver}/src
make DESTDIR="${pkgdir}" EXAMPLEDIR=/usr/share/doc/${pkgname}/examples install
# Fix FS#29889
install -m 644 plugins/kdb/ldap/libkdb_ldap/kerberos.{ldif,schema} "${pkgdir}"/usr/share/doc/${pkgname}/examples
# Sample KDC config file
install -dm 755 "${pkgdir}"/var/lib/krb5kdc
install -pm 644 config-files/kdc.conf "${pkgdir}"/var/lib/krb5kdc/kdc.conf
# Default configuration file
install -dm 755 "${pkgdir}"/etc
install -pm 644 config-files/krb5.conf "${pkgdir}"/etc/krb5.conf
install -dm 755 "${pkgdir}"/usr/share/aclocal
install -m 644 util/ac_check_krb5.m4 "${pkgdir}"/usr/share/aclocal
install -Dm644 "${srcdir}"/${pkgname}-${pkgver}/NOTICE "${pkgdir}"/usr/share/licenses/${pkgname}/LICENSE
# systemd stuff
install -dm 755 "${pkgdir}"/usr/lib/systemd/system
install -m 644 ../../krb5-{kadmind.service,kdc.service,kpropd.service,kpropd@.service,kpropd.socket} \
"${pkgdir}"/usr/lib/systemd/system
}
Btw, $(pkg-config --static --libs libcurl) should include all the libraries you need to link libcurl statically.
Offline
Thanks for answering. Yeah, the building and the installation part went just fine, however, since it built a static-only library, my system just broke, LOL. I couldn't even login. Anyway, it doesn't matter I've already fixed using chroot.
Back to my issue, I don't know if I wasn't clear enough, but I want both static and shared libraries. I don't get it why only this krb5 have to be a pain in the ass.
Offline
Thanks for answering. Yeah, the building and the installation part went just fine, however, since it built a static-only library, my system just broke, LOL. I couldn't even login. Anyway, it doesn't matter I've already fixed using chroot.
Back to my issue, I don't know if I wasn't clear enough, but I want both static and shared libraries. I don't get it why only this krb5 have to be a pain in the ass.
Oh. Sorry about that. I should have known better.
krb5's ./configure does not allow passing --enable-shared and --enable-static at the same time.
A work-around would be creating a dedicated package that only contains static libraries and make it depend on krb5:
_pkgname=krb5
pkgname=krb5-staticlibs
pkgver=1.13.2
pkgrel=1
pkgdesc="The Kerberos network authentication system"
arch=('i686' 'x86_64')
url="http://web.mit.edu/kerberos/"
license=('custom')
depends=("krb5=${pkgver}")
makedepends=('perl' 'yasm')
options=('!emptydirs' 'staticlibs')
source=(http://web.mit.edu/kerberos/dist/krb5/${pkgver%.*}/${_pkgname}-${pkgver}-signed.tar
krb5-config_LDFLAGS.patch)
md5sums=('f7ebfa6c99c10b16979ebf9a98343189'
'c84a0c7d8014e3528524956ffdd1c3e9')
prepare() {
tar -xf ${_pkgname}-${pkgver}.tar.gz
cd ${_pkgname}-${pkgver}
# cf https://bugs.gentoo.org/show_bug.cgi?id=448778
patch -p1 -i "${srcdir}"/krb5-config_LDFLAGS.patch
# FS#25384
sed -i "/KRB5ROOT=/s/\/local//" src/util/ac_check_krb5.m4
}
build() {
cd ${_pkgname}-${pkgver}/src
export CFLAGS+=" -fPIC -fno-strict-aliasing -fstack-protector-all"
./configure --prefix=/usr \
--sbindir=/usr/bin \
--sysconfdir=/etc \
--localstatedir=/var/lib \
--disable-shared \
--enable-static \
--disable-rpath \
--without-tcl \
--enable-dns-for-realm \
--with-ldap \
--without-system-verto
make AS='yasm -D__linux__ -f elf -m amd64' VERTO_LIBS=' -lverto -lm'
}
package() {
cd ${_pkgname}-${pkgver}/src
make DESTDIR="${pkgdir}" EXAMPLEDIR=/usr/share/doc/${_pkgname}/examples install
find ${pkgdir} -type f ! -name '*.a' -delete
}
Offline
Thank you so much! That's exactly what I needed. I just wonder why it doesn't build without all of these yasm parameters... Thanks again!
EDIT: I actually got some error messages while I was compiling the program, then I did a quick research and found this: http://stackoverflow.com/questions/3430 … ng-is-dead
Yeah, I guess I'll forget about it. Hahaha
Last edited by guihkx (2015-11-07 02:33:47)
Offline
I'm kinda new to this programming world, specially in C. I'm just curious to know what am I supposed to do if my program can't run in distros that doesn't have the same curl version as mine. For example, I installed Linux Mint 17.2 (the latest version), updated the whole system and the last curl version available in the repository is 7.40.0 (9 months ago!), while on Arch the last version is _actually_ the last version: 7.45.0. The program simply can't run on Linux Mint:
$ ./program
./program: /usr/lib/i386-linux-gnu/libcurl.so.4: version `CURL_OPENSSL_4' not found (required by ./program)
What experient programmers do to "bypass" this? Compile their program using outdated libraries?
Offline
Static linking is a pain in GNU systems, especially when the distribution is not helping. But it's not impossible.
To link libcurl statically, you need to rebuild the following packages to include static libraries:
* e2fsprogs
* krb5
* glibc
* keyutils
* libidn
* libssh2
* openssl
* rtmpdump
* curl
Note that some static libraries are deleted in the PKGBUILD itself.
To avoid conflicts with e2fsprogs, --with-system-et --with-system-ss should be added back to krb5-staticlibs PKGBUILD.
The command that works:
gcc -o test test.c -Wl,-Bstatic -lcurl -lidn -lrtmp -lssh2 -lssl -lcrypto -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lz -lpthread -lkrb5support -lkeyutils -lresolv -ldl -static-libgcc
On a final note, linked libraries are not the only consideration here. For example, you will probably need to ship a CA bundle file with your binary and set CURLOPT_CAINFO in your code.
Offline
Dear God. Too much pain indeed. I guess I'll leave this idea of static libraries behind, at least until I earn more knowledge about C...
I've set up a virtual machine with Debian and compiled my program with the curl's shared library, then I've also set up another VM with Ubuntu 10.10 (it's an OS from 5 years ago) and ran the program, it worked just fine! So yeah, I'm happy with this approach by now.
Anyway, thank you so much for your help! Cheers.
Offline