OpenWrt Forum Archive

Topic: libldap linking errors

The content of this topic has been archived on 17 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hello all, I was attempting to rebuild my samba3 package for OpenWrt w/ LDAP support. In order to do this I determined that the easiest thing was to simply checkout the CVS buildroot. This is what I get when attempting to build against the libldap that I believe Nico packaged.

configure:30074: checking for ldap_init in -lldap
configure:30102: /home/danielb/OpenWrt/openwrt/staging_dir_mipsel/bin/mipsel-linux-uclibc-gcc -o conftest -Os -pipe -mips32 -mtune=mips32  -D_GNU_SOURCE -DNDEBUG -DSHMEM_SIZE=524288 -Dfcntl=fcntl64 -D_SAMBA_BUILD_ -I/home/danielb/OpenWrt/openwrt/staging_dir_mipsel/usr/include -L/home/danielb/OpenWrt/openwrt/staging_dir_mipsel/lib -L/home/danielb/OpenWrt/openwrt/staging_dir_mipsel/usr/lib -Wl,-rpath /home/danielb/OpenWrt/openwrt/staging_dir_mipsel/usr/lib conftest.c -lldap -llber   -ldl  >&5
/home/danielb/OpenWrt/openwrt/staging_dir_mipsel/lib/gcc/mipsel-linux-uclibc/3.4.4/../../../../mipsel-linux-uclibc/bin/ld: warning: libsasl2.so.2, needed by /home/danielb/OpenWrt/openwrt/staging_dir_mipsel/usr/lib/libldap.so, not found (try using -rpath or -rpath-link)
/home/danielb/OpenWrt/openwrt/staging_dir_mipsel/lib/gcc/mipsel-linux-uclibc/3.4.4/../../../../mipsel-linux-uclibc/bin/ld: warning: libssl.so.0.9.7, needed by /home/danielb/OpenWrt/openwrt/staging_dir_mipsel/usr/lib/libldap.so,
not found (try using -rpath or -rpath-link)
/home/danielb/OpenWrt/openwrt/staging_dir_mipsel/lib/gcc/mipsel-linux-uclibc/3.4.4/../../../../mipsel-linux-uclibc/bin/ld: warning: libcrypto.so.0.9.7, needed by /home/danielb/OpenWrt/openwrt/staging_dir_mipsel/usr/lib/libldap.so, not found (try using -rpath or -rpath-link)
/home/danielb/OpenWrt/openwrt/staging_dir_mipsel/usr/lib/libldap.so: undefined reference to `SSL_CTX_set_tmp_rsa_callback'
/home/danielb/OpenWrt/openwrt/staging_dir_mipsel/usr/lib/libldap.so: undefined reference to `RAND_load_file'
/home/danielb/OpenWrt/openwrt/staging_dir_mipsel/usr/lib/libldap.so: undefined reference to `ssl3_send_alert'
/home/danielb/OpenWrt/openwrt/staging_dir_mipsel/usr/lib/libldap.so: undefined reference to `RAND_write_file'
/home/danielb/OpenWrt/openwrt/staging_dir_mipsel/usr/lib/libldap.so: undefined reference to `sk_new_null'
/home/danielb/OpenWrt/openwrt/staging_dir_mipsel/usr/lib/libldap.so: undefined reference to `RSA_generate_key'
/home/danielb/OpenWrt/openwrt/staging_dir_mipsel/usr/lib/libldap.so: undefined reference to `sasl_client_step'
/home/danielb/OpenWrt/openwrt/staging_dir_mipsel/usr/lib/libldap.so: undefined reference to `sasl_getprop'
/home/danielb/OpenWrt/openwrt/staging_dir_mipsel/usr/lib/libldap.so: undefined reference to `SSL_CTX_free'
/home/danielb/OpenWrt/openwrt/staging_dir_mipsel/usr/lib/libldap.so: undefined reference to `X509_free'
/home/danielb/OpenWrt/openwrt/staging_dir_mipsel/usr/lib/libldap.so: undefined reference to `SSL_load_client_CA_file'
.
.
.
etc.

The Makefile that I am using (which is based on what was in cvs for the Samba 2.0.10 package is as follows:

include $(TOPDIR)/rules.mk

PKG_NAME:=samba
PKG_VERSION:=3.0.20b
PKG_RELEASE:=1
PKG_MD5SUM:=39c0cae08fe0224cb003aa0af97d3050

PKG_SOURCE_URL:=ftp://se.samba.org/pub/samba/stable \
        ftp://ftp.easynet.be/samba/stable
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_CAT:=zcat
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install

include $(TOPDIR)/package/rules.mk

$(eval $(call PKG_template,SAMBA,samba,$(PKG_VERSION)-$(PKG_RELEASE),$(ARCH)))
$(eval $(call PKG_template,SAMBA_CLIENT,samba-client,$(PKG_VERSION)-$(PKG_RELEASE),$(ARCH)))

conf_args = \
                --target=$(GNU_TARGET_NAME) \
                --host=$(GNU_TARGET_NAME) \
                --build=$(GNU_HOST_NAME) \
                --with-fhs \
                --enable-shared \
                --enable-static \
                --disable-xmltest \
                --disable-cups \
                --prefix=/usr \
                --sysconfdir=/etc \
                --with-libdir=/usr/share/samba \
                --with-privatedir=/etc/samba \
                --with-piddir=/var/run/samba \
                --localstatedir=/var \
                --with-syslog \
                --with-ldap \
                --with-ldapsam

$(PKG_BUILD_DIR)/.configured:
        (cd $(PKG_BUILD_DIR)/source; rm -rf config.{cache,status}; \
                $(TARGET_CONFIGURE_OPTS) \
                CFLAGS="$(TARGET_CFLAGS) -D_GNU_SOURCE -DNDEBUG -DSHMEM_SIZE=524288 -Dfcntl=fcntl64" \
                CPPFLAGS="-I$(STAGING_DIR)/usr/include" \
                LDFLAGS="-L$(STAGING_DIR)/lib -L$(STAGING_DIR)/usr/lib" \
                LD_RUN_PATH="$(STAGING_DIR)/lib $(STAGING_DIR)/usr/lib" \
                ac_cv_lib_cups_httpConnect=no \
                ac_cv_sizeof_int=4 \
                ac_cv_sizeof_long=4 \
                ac_cv_sizeof_short=2 \
                samba_cv_FTRUNCATE_NEEDS_ROOT=no \
                samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=no \
                samba_cv_HAVE_BROKEN_GETGROUPS=no \
                samba_cv_HAVE_BROKEN_READDIR=no \
                samba_cv_HAVE_FCNTL_LOCK=yes \
                samba_cv_HAVE_FNMATCH=yes \
                samba_cv_HAVE_FTRUNCATE_EXTEND=no \
                samba_cv_HAVE_GETTIMEOFDAY_TZ=yes \
                samba_cv_HAVE_IFACE_AIX=no \
                samba_cv_HAVE_IFACE_IFCONF=yes \
                samba_cv_HAVE_IFACE_IFREQ=yes \
                samba_cv_HAVE_INO64_T=yes \
                samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES=no \
                samba_cv_HAVE_OFF64_T=yes \
                samba_cv_HAVE_ROOT=yes \
                samba_cv_HAVE_SECURE_MKSTEMP=yes \
                samba_cv_HAVE_SHARED_MMAP=yes \
                samba_cv_HAVE_STRUCT_FLOCK64=yes \
                samba_cv_HAVE_SYSV_IPC=no \
                samba_cv_HAVE_TRUNCATED_SALT=no \
                samba_cv_HAVE_UNION_SEMUN=no \
                samba_cv_HAVE_UNSIGNED_CHAR=yes \
                samba_cv_NEED_SGI_SEMUN_HACK=no \
                samba_cv_REPLACE_INET_NTOA=no \
                samba_cv_SIZEOF_INO_T=4 \
                samba_cv_SIZEOF_OFF_T=4 \
                samba_cv_SYSCONF_SC_NGROUPS_MAX=yes \
                samba_cv_USE_SETEUID=yes \
                samba_cv_USE_SETRESUID=no \
                samba_cv_USE_SETREUID=yes \
                samba_cv_USE_SETUIDX=no \
                samba_cv_have_longlong=yes \
                samba_cv_have_setresgid=no \
                samba_cv_have_setresuid=no \
                ./configure $(conf_args) \
        );
        touch $@

$(PKG_BUILD_DIR)/.built:
        rm -rf $(PKG_INSTALL_DIR)
        $(MAKE) -C $(PKG_BUILD_DIR)/source \
                $(TARGET_CONFIGURE_OPTS) \
                all
        $(MAKE) -C $(PKG_BUILD_DIR)/source \
                BASEDIR="$(PKG_INSTALL_DIR)/usr" \
                BINDIR="$(PKG_INSTALL_DIR)/usr/bin" \
                SBINDIR="$(PKG_INSTALL_DIR)/usr/bin" \
                LIBDIR="$(PKG_INSTALL_DIR)/usr/share/samba" \
               VARDIR="$(PKG_INSTALL_DIR)/var/log/samba" \
                MANDIR="$(PKG_INSTALL_DIR)/usr/share/man" \
                CONFIGDIR="$(PKG_INSTALL_DIR)/etc/samba" \
                PRIVATEDIR="$(PKG_INSTALL_DIR)/etc/samba" \
                SWATDIR="$(PKG_INSTALL_DIR)/usr/swat" \
                LOCKDIR="$(PKG_INSTALL_DIR)/var/run/samba" \
                SAMBABOOK="$(PKG_INSTALL_DIR)/usr/swat/using_samba" \
                CODEPAGEDIR="$(PKG_INSTALL_DIR)/usr/share/samba" \
                install
        touch $@

$(IPKG_SAMBA):
        install -d -m0755 $(IDIR_SAMBA)/etc/init.d
        install -m0755 ./files/samba.init $(IDIR_SAMBA)/etc/init.d/samba
        install -d -m0755 $(IDIR_SAMBA)/etc/samba
        install -m0644 ./files/smb.conf $(IDIR_SAMBA)/etc/samba/smb.conf
        install -d -m0755 $(IDIR_SAMBA)/usr/bin
        install -m0755 $(PKG_BUILD_DIR)/source/bin/net $(IDIR_SAMBA)/usr/bin/
        install -m0755 $(PKG_BUILD_DIR)/source/bin/nmblookup $(IDIR_SAMBA)/usr/bin/
        install -m0755 $(PKG_BUILD_DIR)/source/bin/smbpasswd $(IDIR_SAMBA)/usr/bin/
        install -m0755 $(PKG_BUILD_DIR)/source/bin/testparm $(IDIR_SAMBA)/usr/bin/
        install -d -m0755 $(IDIR_SAMBA)/usr/share/samba
        install -m0644 $(PKG_INSTALL_DIR)/usr/share/samba/lowcase.dat $(IDIR_SAMBA)/usr/share/samba/
        install -m0644 $(PKG_INSTALL_DIR)/usr/share/samba/upcase.dat $(IDIR_SAMBA)/usr/share/samba/
        install -m0644 $(PKG_INSTALL_DIR)/usr/share/samba/valid.dat $(IDIR_SAMBA)/usr/share/samba/
        install -m0755 $(PKG_BUILD_DIR)/source/bin/smbstatus $(IDIR_SAMBA)/usr/bin/
        install -m0755 $(PKG_BUILD_DIR)/source/bin/smbcontrol $(IDIR_SAMBA)/usr/bin/
        install -m0755 $(PKG_BUILD_DIR)/source/bin/tdbbackup $(IDIR_SAMBA)/usr/bin/
        install -m0755 $(PKG_BUILD_DIR)/source/bin/pdbedit $(IDIR_SAMBA)/usr/bin/
        install -d -m0755 $(IDIR_SAMBA)/usr/sbin
        install -m0755 $(PKG_BUILD_DIR)/source/bin/nmbd $(IDIR_SAMBA)/usr/sbin/
        install -m0755 $(PKG_BUILD_DIR)/source/bin/smbd $(IDIR_SAMBA)/usr/sbin/
        $(RSTRIP) $(IDIR_SAMBA)
        $(IPKG_BUILD) $(IDIR_SAMBA) $(PACKAGE_DIR)

$(IPKG_SAMBA_CLIENT):
        install -d -m0755 $(IDIR_SAMBA_CLIENT)/usr/bin
        install -m0755 $(PKG_INSTALL_DIR)/usr/bin/smbclient $(IDIR_SAMBA_CLIENT)/usr/bin/
        install -m0755 $(PKG_INSTALL_DIR)/usr/bin/smbtar $(IDIR_SAMBA_CLIENT)/usr/bin/
        install -m0755 $(PKG_INSTALL_DIR)/usr/bin/rpcclient $(IDIR_SAMBA_CLIENT)/usr/bin/
        install -m0755 $(PKG_INSTALL_DIR)/usr/bin/smbspool $(IDIR_SAMBA_CLIENT)/usr/bin/
        install -m0755 $(PKG_INSTALL_DIR)/usr/bin/smbtree $(IDIR_SAMBA_CLIENT)/usr/bin/
        install -m0755 $(PKG_INSTALL_DIR)/usr/bin/smbcacls $(IDIR_SAMBA_CLIENT)/usr/bin/
        install -m0755 $(PKG_INSTALL_DIR)/usr/bin/smbcquotas $(IDIR_SAMBA_CLIENT)/usr/bin/
        $(RSTRIP) $(IDIR_SAMBA_CLIENT)
        $(IPKG_BUILD) $(IDIR_SAMBA_CLIENT) $(PACKAGE_DIR)

mostlyclean:
        -$(MAKE) -C $(PKG_BUILD_DIR) clean
        rm -f $(PKG_BUILD_DIR)/.built

Just wondering if anyone can provide a helping hand. I am not a wizard and compiling things but typically I know enough to get by wink. I guess I am just a little stuck. I even tried this at one point (by just following what the linker told me)

LDFLAGS="-L$(STAGING_DIR)/lib -L$(STAGING_DIR)/usr/lib -Wl,-rpath $(STAGING_DIR)/usr/lib" \

but it did not help. I was later told by someone in #samba on freenode that this is not the correct usage for -rpath anyway. They also mentioned rebuilding libldap with -rpath or some such thing.

Any help on this matter would be appreciated.

Dan

(Last edited by chillywilly on 29 Oct 2005, 02:54)

Replying to my own post here. I finally broke down and read about the -rpath and -rpath-link options in the ld man page. I was able to get configure to link to libldap when I added the following line to LDFLAGS in the Makefile

-Wl,-rpath-link $(STAGING_DIR)/lib -Wl,-rpath-link $(STAGING_DIR)/usr/lib

Now I just need to read through the rest of the configure options as it seems there's a few things I need to disable. Thanks anyway!

Dan

The discussion might have continued from here.