Menu

Linker Error OpenWRT whiterussian SDK

Help
Ben08
2008-03-11
2012-12-14
  • Ben08

    Ben08 - 2008-03-11

    After successfully compiling pthsem, curl, libesmtp, argp and uCLib++-0.2.2 linknx-0.0.1.23 won't compile giving what looks like a linker error:

    Configure messages:

    configure: loading site script /home/bern/OpenWrt-SDK-Linux-i686-1/include/site/mipsel-linux-uclibc
    checking for a BSD-compatible install... /usr/bin/install -c
    checking whether build environment is sane... yes
    checking for gawk... gawk
    checking whether make sets $(MAKE)... yes
    checking for mipsel-linux-strip... mipsel-linux-uclibc-strip
    checking for C++ compiler default output file name... a.out
    checking whether the C++ compiler works... yes
    checking whether we are cross compiling... yes
    checking for suffix of executables...
    checking for suffix of object files... o
    checking whether we are using the GNU C++ compiler... yes
    checking whether mipsel-linux-uclibc-g++ accepts -g... yes
    checking for style of include used by make... GNU
    checking dependency style of mipsel-linux-uclibc-g++... gcc3
    checking for mipsel-linux-gcc... mipsel-linux-uclibc-gcc
    checking whether we are using the GNU C compiler... yes
    checking whether mipsel-linux-uclibc-gcc accepts -g... yes
    checking for mipsel-linux-uclibc-gcc option to accept ISO C89... none needed
    checking dependency style of mipsel-linux-uclibc-gcc... gcc3
    checking for mipsel-linux-ranlib... mipsel-linux-uclibc-ranlib
    checking how to run the C preprocessor... mipsel-linux-uclibc-gcc -E
    checking for GNU Pth... version 2.0.7, uninstalled under /home/bern/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel
    checking for grep that handles long lines and -e... /bin/grep
    checking for egrep... /bin/grep -E
    checking for ANSI C header files... yes
    checking for sys/types.h... yes
    checking for sys/stat.h... yes
    checking for stdlib.h... yes
    checking for string.h... yes
    checking for memory.h... yes
    checking for strings.h... yes
    checking for inttypes.h... yes
    checking for stdint.h... yes
    checking for unistd.h... yes
    checking argp.h usability... yes
    checking argp.h presence... yes
    checking for argp.h... yes
    checking for library containing argp_parse... -largp
    checking for cppunit-config... no
    checking for Cppunit - version >= 1.9.6... checking for gawk... (cached) gawk
    checking for curl-config... /home/bern/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel/usr/bin/curl-config
    checking for the version of libcurl... 7.14.0
    checking for libcurl >= version 7.14.0... yes
    checking whether libcurl is usable... yes
    checking for curl_free... yes
    checking for ANSI C header files... (cached) yes
    checking fcntl.h usability... yes
    checking fcntl.h presence... yes
    checking for fcntl.h... yes
    checking stddef.h usability... yes
    checking stddef.h presence... yes
    checking for stddef.h... yes
    checking for stdlib.h... (cached) yes
    checking for unistd.h... (cached) yes
    checking for mysql_config executable... not found
    checking libesmtp.h usability... yes
    checking libesmtp.h presence... yes
    checking for libesmtp.h... yes
    checking whether to use libesmtp... ./configure: line 8317: libesmtp-config: command not found
    ./configure: line 8318: libesmtp-config: command not found
    yes
    checking for stdbool.h that conforms to C99... yes
    checking for _Bool... yes
    checking for an ANSI C-conforming const... yes
    checking for inline... inline
    checking for int16_t... yes
    checking for size_t... yes
    checking for uint16_t... yes
    checking for uint8_t... yes
    checking for ptrdiff_t... yes
    checking for pid_t... yes
    checking vfork.h usability... no
    checking vfork.h presence... no
    checking for vfork.h... no
    checking for fork... yes
    checking for vfork... yes
    checking for working fork... cross
    configure: WARNING: result yes guessed because of cross compilation
    checking for working vfork... (cached) yes
    checking return type of signal handlers... void
    checking for vprintf... yes
    checking for _doprnt... no
    checking for dup2... yes
    checking for memmove... yes
    checking for memset... yes
    checking for strchr... yes
    configure: creating ./config.status
    config.status: creating Makefile
    config.status: creating src/Makefile
    config.status: creating ticpp/Makefile
    config.status: creating include/Makefile
    config.status: creating test/Makefile
    config.status: creating conf/Makefile
    config.status: creating config.h
    config.status: executing depfiles commands
    touch /home/bern/OpenWrt-SDK-Linux-i686-1/build_mipsel/linknx-0.0.1.23/.configured
    CFLAGS="-Os -pipe -mips32 -mtune=mips32 -funit-at-a-time -I/home/bern/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel/usr/include -I/home/bern/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel/include " LDFLAGS="-L/home/bern/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel/usr/lib -L/home/bern/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel/lib " make -C /home/bern/OpenWrt-SDK-Linux-i686-1/build_mipsel/linknx-0.0.1.23 AR=mipsel-linux-uclibc-ar AS="mipsel-linux-uclibc-gcc -c -Os -pipe -mips32 -mtune=mips32 -funit-at-a-time" LD=mipsel-linux-uclibc-ld NM=mipsel-linux-uclibc-nm CC="mipsel-linux-uclibc-gcc" GCC="mipsel-linux-uclibc-gcc" CXX=mipsel-linux-uclibc-g++ RANLIB=mipsel-linux-uclibc-ranlib STRIP=mipsel-linux-uclibc-strip OBJCOPY=mipsel-linux-uclibc-objcopy CROSS="mipsel-linux-uclibc-" CXXFLAGS="-Os -pipe -mips32 -mtune=mips32 -funit-at-a-time -I/home/bern/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel/usr/include -I/home/bern/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel/include " ARCH="mipsel" ;

    compile error:

    mipsel-linux-uclibc-g++  -Os -pipe -mips32 -mtune=mips32 -funit-at-a-time -I/home/bern/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel/usr/include -I/home/bern/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel/include   -nodefaultlibs -L/home/bern/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel/usr/lib -L/home/bern/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel/lib -luClibc++-0.2.2 -lc -lm -lgcc -o linknx  linknx.o ruleserver.o objectcontroller.o common.o eibclient.o threads.o timermanager.o persistentstorage.o xmlserver.o smsgateway.o emailgateway.o knxconnection.o services.o ../ticpp/libticpp.a -L/home/bern/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel/usr/lib -lpthsem -lcurl -L/home/bern/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel/usr/lib -L/home/bern/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel/lib -ldl -lz -lm -largp
    linknx.o: In function `main':
    linknx.cpp:(.text+0x764): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::_Rep::_S_empty_rep_storage'
    linknx.cpp:(.text+0x77c): undefined reference to `__gnu_cxx::__exchange_and_add(int volatile*, int)'
    linknx.cpp:(.text+0x790): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::_Rep::_M_destroy(std::allocator<char> const&)'
    linknx.cpp:(.text+0x7b4): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::_Rep::_S_empty_rep_storage'
    linknx.cpp:(.text+0x7c8): undefined reference to `__gnu_cxx::__exchange_and_add(int volatile*, int)'
    ...

    Can anybody point me in the right direction which C++ library to link against?

    Thanks,
    Bernhard

     
    • jef2000

      jef2000 - 2008-03-11

      Hi,

      Perhaps the problem is linked to optimization flag ( see: http://gcc.gnu.org/ml/gcc-bugs/2004-02/msg00354.html )
      Does it work if you try to compile with flag -O0 instead of -Os ?
      I don't remember which flag I'm using when I compile linknx... I'll have a look at it this evening.

      Regards,

      Jean-François

       
    • Ben08

      Ben08 - 2008-03-11

      Dear Jean-François,

      I changed the optimisation flag in .config as you suggested.

      make[4]: Entering directory `/home/bern/OpenWrt-SDK-Linux-i686-1/package/linknx'
      CFLAGS="-O0 -pipe -mips32 -mtune=mips32 -funit-at-a-time -I/home/bern/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel/usr/include -I/home/bern/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel/include " LDFLAGS="-L/home/bern/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel/usr/lib -L/home/bern/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel/lib " make -C /home/bern/OpenWrt-SDK-Linux-i686-1/build_mipsel/linknx-0.0.1.23 AR=mipsel-linux-uclibc-ar AS="mipsel-linux-uclibc-gcc -c -O0 -pipe -mips32 -mtune=mips32 -funit-at-a-time" LD=mipsel-linux-uclibc-ld NM=mipsel-linux-uclibc-nm CC="mipsel-linux-uclibc-gcc" GCC="mipsel-linux-uclibc-gcc" CXX=mipsel-linux-uclibc-g++ RANLIB=mipsel-linux-uclibc-ranlib STRIP=mipsel-linux-uclibc-strip OBJCOPY=mipsel-linux-uclibc-objcopy CROSS="mipsel-linux-uclibc-" CXXFLAGS="-O0 -pipe -mips32 -mtune=mips32 -funit-at-a-time -I/home/bern/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel/usr/include -I/home/bern/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel/include " ARCH="mipsel" ;

      The error though is still the same. I used and adapted the linknx-0.1.20 Makefile.
      As it turns out, I cannot build any linknx package for whiterussian-0.9, all other ipkg compile without any problem.

      I subsequently reinstalled the whiterussian SDK, unfortunately to no avail.

      What OpenWRT SDK are you using?

      Thanks,
      Bernhard

       
    • jef2000

      jef2000 - 2008-03-11

      I tried it with whiterussian RC6 coming from here:
      http://downloads.openwrt.org/whiterussian/rc6/OpenWrt-SDK-Linux-i686-1.tar.bz2
      And it works.....
      But if I do the same with whiterussian 0.9 coming from here:
      http://downloads.openwrt.org/whiterussian/0.9/OpenWrt-SDK-Linux-i686-1.tar.bz2
      And see the same error message as you.

      No idea what they changed between RC6 and 0.9 ...

      Regards,

      Jean-François

       
    • jef2000

      jef2000 - 2008-03-11

      Hi,

      I found the problem. OpenWrt has changed some makefile rules related to CXXFLAGS and CPPFLAGS. The result was that -fno-builtin and -nostdinc++ flags are ignored in 0.9.

      In packages/linknx/Makefile, I changed:

      define Build/Configure
          $(call Build/Configure/Default,--without-pth-test --with-pth=$(STAGING_DIR) --without-mysql,\                         CXXFLAGS="$(TARGET_CFLAGS) -fno-builtin -nostdinc++" \                         CPPFLAGS="-I$(STAGING_DIR)/usr/include -I$(STAGING_DIR)/include" \                         LDFLAGS="-nodefaultlibs -L$(STAGING_DIR)/usr/lib -L$(STAGING_DIR)/lib -luClibc++ -lc -lm -lgcc")
      endef

      To:

      define Build/Configure
          $(call Build/Configure/Default,--without-pth-test --with-pth=$(STAGING_DIR) --without-mysql,\                         CXXFLAGS="$(TARGET_CFLAGS)" \                         CPPFLAGS="-I$(STAGING_DIR)/usr/include -I$(STAGING_DIR)/include -fno-builtin -nostdinc++" \                         LDFLAGS="-nodefaultlibs -L$(STAGING_DIR)/usr/lib -L$(STAGING_DIR)/lib -luClibc++ -lc -lm -lgcc")
      endef

      And it works.

      Regards,

      Jean-François

       
    • Ben08

      Ben08 - 2008-03-12

      Dear JF,

      thanks for the above. I followed your suggestions and run now into another issue on both whiterussian RC06 as well as 09. It seems as if I am missing a library related to emailgateway.cpp, but which one?

      Making all in src
      make[7]: Entering directory `/home/bern/OpenWrt-SDK-Linux-i686-09/build_mipsel/linknx-0.0.1.17/src'
      mipsel-linux-uclibc-g++  -Os -pipe -mips32 -mtune=mips32 -funit-at-a-time -I/home/bern/OpenWrt-SDK-Linux-i686-09/staging_dir_mipsel/usr/include -I/home/bern/OpenWrt-SDK-Linux-i686-09/staging_dir_mipsel/include   -nodefaultlibs -L/home/bern/OpenWrt-SDK-Linux-i686-09/staging_dir_mipsel/usr/lib -L/home/bern/OpenWrt-SDK-Linux-i686-09/staging_dir_mipsel/lib -luClibc++ -lc -lm -lgcc -o linknx  linknx.o ruleserver.o objectcontroller.o common.o eibclient.o threads.o timermanager.o persistentstorage.o xmlserver.o smsgateway.o emailgateway.o knxconnection.o services.o ../ticpp/libticpp.a -L/home/bern/OpenWrt-SDK-Linux-i686-09/staging_dir_mipsel/usr/lib -lpthsem -lcurl -L/home/bern/OpenWrt-SDK-Linux-i686-09/staging_dir_mipsel/usr/lib -L/home/bern/OpenWrt-SDK-Linux-i686-09/staging_dir_mipsel/lib -ldl -lz -largp
      emailgateway.o: In function `EmailGateway::sendEmail(std::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >&)':
      emailgateway.cpp:(.text+0x9ec): undefined reference to `smtp_create_session'
      emailgateway.cpp:(.text+0xa00): undefined reference to `smtp_add_message'
      emailgateway.cpp:(.text+0xa44): undefined reference to `smtp_set_server'
      emailgateway.cpp:(.text+0xa84): undefined reference to `smtp_set_reverse_path'
      emailgateway.cpp:(.text+0xaa0): undefined reference to `smtp_set_header'
      emailgateway.cpp:(.text+0xaf4): undefined reference to `smtp_set_header'
      emailgateway.cpp:(.text+0xb1c): undefined reference to `smtp_set_header_option'
      emailgateway.cpp:(.text+0xb30): undefined reference to `smtp_set_messagecb'
      emailgateway.cpp:(.text+0xb74): undefined reference to `smtp_add_recipient'
      emailgateway.cpp:(.text+0xb84): undefined reference to `smtp_start_session'
      emailgateway.cpp:(.text+0xbb0): undefined reference to `smtp_errno'
      emailgateway.cpp:(.text+0xbc8): undefined reference to `smtp_strerror'
      emailgateway.cpp:(.text+0xbf4): undefined reference to `smtp_message_transfer_status'
      emailgateway.cpp:(.text+0xc7c): undefined reference to `smtp_destroy_session'
      collect2: ld returned 1 exit status

      The error shows with libesmtp build with and without openssl support (for smtpauth).

      I really appreciate your help on this!

      Regards,
      Bernhard

      PS: compiling on my Debian/sid laptop works without fail.

       
    • jef2000

      jef2000 - 2008-03-13

      Hi,

      Normally, the linker comman line should contain "-lesmtp" just after  "-lpthsem -lcurl"
      I don't know why it's not the case...
      The following macro in configure.ac should set it to the appropriate value when smtp is enabled:
          ESMTP_CFLAGS="`libesmtp-config --cflags`"
          ESMTP_LIBS="`libesmtp-config --libs`"
          CFLAGS="$ESMTP_CFLAGS $CFLAGS"
          LIBS="$ESMTP_LIBS $LIBS"

      You can try to execute "libesmtp-config --libs" manually to see if the output contains "-lesmtp". If it's not the case, your libesmtp is not installed correctly. If it's the case, the problem comes from linknx.

      Regards,

      Jean-François

       
    • Ben08

      Ben08 - 2008-03-13

      Dear JF,

      using your suggestion to look into libesmtp I finally managed to get it to work. It turned out that although the libesmtp package was successfully build, vital files were not copied into the build environment which in turn failed to compile linknx correctly. Here is my recipe - worked for me cooking on a SIDUX - Debian/Sid FSC Lifebook with OpenWRT whiterussian 0.9 SDK :

      1. Download Openwrt-whiterussian SDK 0.9 and install in user's root dir
      2. Download OpenWRT whiterussian makefiles for argp, curl, libesmpt, uClibc++, pthsem, linknx package from http://ouaye.net/linknx/OpenWRT-WhiteRussian-RC6/build/ and unpack into package directory
      3. Remove TAR_OPTIONS:=-xf from uClibc++ and curl
      4. compile with "make V=99"

      For me compiling in this order worked eventually (unpack archive, then run "make V=99" straight afterwards, then unpack next archive, ...):  uClibc++, argp, pthsem, curl, libesmtp

      If download of sources fails for pthsem and argp, replace PKG_SOURCE_URL:=@SF/bcusdk with PKG_SOURCE_URL:=http://www.mirrorservice.org/sites/download.sourceforge.net/pub/sourceforge/b/bc/bcusdk 

      Compiling linknx package:

      1. Unzip makefile into package directory
      2. edit makefile:
         PKG_VERSION:=0.0.1.23
         PKG_MD5SUM:= (leave empty, or if you know the checksum for the archive, you can also put it in - I did not bother.)

         define Build/Configure
          $(call Build/Configure/Default,--without-pth-test --with-pth=$(STAGING_DIR),\                         CXXFLAGS="$(TARGET_CFLAGS) " \                         CPPFLAGS="-I$(STAGING_DIR)/usr/include -I$(STAGING_DIR)/include -fno-builtin -nostdinc++" \                         LDFLAGS="-nodefaultlibs -L$(STAGING_DIR)/usr/lib -L$(STAGING_DIR)/lib -luClibc++ -lc -lm -lgcc")
         endef

      3. edit .config in OpenWrt-SDK-Linux-i686-1 root directory:
         CONFIG_TARGET_OPTIMIZATION="-O0 -pipe -mips32 -mtune=mips32 -funit-at-a-time"
         you might not need to do this, but I had to in order to get linknx to compile. All other above mentioned packages compiled without this change in the optimisation flag.

      4. Verify that libesmtp has properly installed into your build environment. You should see all files from .../build_mipsel/libesmtp-1.0.4/ipkg-install/usr in .../staging_dir_mipsel/usr as well!! In my case the libesmtp-config script was missing in /staging_dir_mipsel/usr/bin so linknx would not compile.

      5. compile with "make V=99"

      Then transfer and install on WRT as usual.

      Thanks again for your excellent piece of software and all your help!!!

      Bernhard
       

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.