OpenWrt Forum Archive

Topic: cross compiling with SDK - How openwrt ends up locating libc.so.6?

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

Hi all,

I am building a simple package for my openwrt instance running on a small pc, however currently i am stuck with missing library file problem:

libc.so.6

Using attitude adjustment sdk from: http://downloads.openwrt.org/attitude_a … 6/generic/
My linux environment:  Linux qq-VirtualBox 3.2.0-23-generic #36-Ubuntu SMP Tue Apr 10 20:41:14 UTC 2012 i686 i686 i386 GNU/Linux

This is what i did to get the problem:

Download the sdk, extracted and place my package folder under /buildroot/package, create a makefile as instructed:
================================Makefile============================================
include $(TOPDIR)/rules.mk

PKG_NAME:memwatch
PKG_VERSION:=1.0.0
PKG_RELASE:=1
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)

include $(INCLUDE_DIR)/package.mk

define Package/memwatch
    SECTION:=utils
    CATEGORY:=Utilities
    TITLE:=MemoryWatcher
endef

define Package/$(PKG_NAME)/description
    this is a memory watch utility
endef

define Build/Prepare
    @echo -----------------------------------running build/prepare...
    mkdir -p $(PKG_BUILD_DIR)
    $(CP) ./src/* $(PKG_BUILD_DIR)/
endef

define Package/memwatch/install
    @echo
    @echo -----------------------------------running Package/memwatch/install ...
    $(INSTALL_DIR) $(1)/bin
    $(INSTALL_BIN) $(PKG_BUILD_DIR)/memwatch $(1)/bin/
    @echo
    @echo -----------------------------------installation finished
    @echo
endef

$(eval $(call BuildPackage,memwatch))

====================================end Makefile===========================================


got the following error during make V=s:

========================================make V=s========================================================


tmp/.config-package.in:11:warning: 'select' used by config symbol 'PACKAGE_memwatch' refer to undefined symbol 'PACKAGE_libc'
tmp/.config-package.in:12:warning: 'select' used by config symbol 'PACKAGE_memwatch' refer to undefined symbol 'PACKAGE_librt'
tmp/.config-package.in:13:warning: 'select' used by config symbol 'PACKAGE_memwatch' refer to undefined symbol 'PACKAGE_libpthread'
#
# using defaults found in .config
#


*** End of OpenWrt configuration.
*** Execute 'make' to build the OpenWrt or try 'make help'.

make[1]: Entering directory `/home/qq/Downloads/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2'
make[2]: Entering directory `/home/qq/Downloads/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2'
make[3]: Entering directory `/home/qq/Downloads/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/package/memwatch'
mkdir -p /home/qq/Downloads/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/bin//packages /home/qq/Downloads/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/build_dir/target-_-/-1.0.0/ipkg-/memwatch/CONTROL /home/qq/Downloads/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/target-_-/pkginfo

-----------------------------------running Package/memwatch/install ...
install -d -m0755 /home/qq/Downloads/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/build_dir/target-_-/-1.0.0/ipkg-/memwatch/bin
install -m0755 /home/qq/Downloads/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/build_dir/target-_-/-1.0.0/memwatch /home/qq/Downloads/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/build_dir/target-_-/-1.0.0/ipkg-/memwatch/bin/

-----------------------------------installation finished

find /home/qq/Downloads/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/build_dir/target-_-/-1.0.0/ipkg-/memwatch -name 'CVS' -o -name '.svn' -o -name '.#*' -o -name '*~'| xargs -r rm -rf
Package memwatch is missing dependencies for the following libraries:
libc.so.6
libstdc++.so.6
make[3]: *** [/home/qq/Downloads/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/bin//packages/memwatch_1.0.0_.ipk] Error 1
make[3]: Leaving directory `/home/qq/Downloads/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/package/memwatch'
make[2]: *** [package/memwatch/compile] Error 2
make[2]: Leaving directory `/home/qq/Downloads/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2'
make[1]: *** [/home/qq/Downloads/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/target-_-/stamp/.package_compile] Error 2
make[1]: Leaving directory `/home/qq/Downloads/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2'
make: *** [world] Error 2
============================================end make V=s====================================================


Make is complaining about missing library so files, which I belive creating symlinks could possibly resolve the problem, but I want to know for sure where in the makefile is actually stating where to look for these so files...

I managed to trace to the following under buildroot/include/package-defaults.mk, which has these dependency defined:

PKG_DEFAULT_DEPENDS = +libc +USE_EGLIBC:librt +USE_EGLIBC:libpthread

however I am not sure whether this line is of any relation with the missing libc.so.6 file?
how does the makefile converts these dependency lines into the actual filenames?

please help

ok, i am going to answer to myself again,
after some digging, i found that package-ipkg.mk is looking $(PKG_INFO_DIR)/$(1).provides

this $(1) are the arguments in the DEPENDS: phrase,

so I must look for the available libstdcpp.provide file which includes:

libstdc++.so.6
libstdc++.so.6.0.16
libstdc++.so.6.0.16-gdb.py

so for any missing dependencies the make is requesting, you need to look for your_staging_dir / target_xxx / pkg_info /your_wanted_import.provide for these library names. and use them in your DEPENDS prase under the Makefile.

hope this helps.

(Last edited by robertlee on 4 Feb 2013, 08:44)

Hi Robert, can you explain the solution a little more?  I am having the same problem, but honestly can't understand how you fixed it.  Would you be able to provide more concrete example, like your updated Makefile so I can see what you changed?  Thank you!

Guys,

I have successfully compiled the popular helloworld c++ example (https://github.com/airplug/airplug/wiki … or-OpenWRT).

To give more details about Robert's solution, you need to
1) Install libc++ in openwrt by "opkg update; opkg install libstdcpp"
2) Copy "/usr/lib/libstdc++.so.6.0.16" from your openwrt box to  "staging_dir/target-i386_uClibc-0.9.33.2/usr/lib" on your host machine for cross-compilation.
3) Go to staging_dir/target-i386_uClibc-0.9.33.2/usr/lib and create a symbolic link: "ln -s libstdc++.so.6.0.16 libstdc++.so.6". This libstdc++.so.6 is the c++ standard library.
4) Add DEPENDS:=+libstdcpp in your package Makefile, e.g.,

define Package/helloworld
  SECTION:=utils
  CATEGORY:=Utilities
  TITLE:=Helloworld -- prints a snarky message
  DEPENDS:=+libstdcpp
endef

Keep the rest of makefile same as the original example. That's it! Hope this can help.

Tan

you only have to set the depedencies:

when you see a compile error:

Package helloworld is missing dependencies for the following libraries:
libc.so.6
libstdc++.so.6

The you have to make changes in the package Makefile:

define Package/helloworld
  ...
  DEPENDS:=+libstdcpp +libc
  ...
endef

You dont have to install with opkg on the target, and then copy back to staging_dir the depedencies.

(Last edited by GABIKA6 on 11 Sep 2013, 15:12)

Sorry for digging this up but nobody seems to be able to answer this problem. When I try to compile my package, I get the following error:

Package amld is missing dependencies for the following libraries:
libc.so.6
make[3]: *** [/home/michael/Documents/openwrt/openwrt/bin/x86/packages/amld_1_x86.ipk] Error 1
make[3]: Leaving directory `/home/michael/Documents/openwrt/openwrt/package/amld'
make[2]: *** [package/amld/compile] Error 2
make[2]: Leaving directory `/home/michael/Documents/openwrt/openwrt'
make[1]: *** [/home/michael/Documents/openwrt/openwrt/staging_dir/target-i386_i486_uClibc-0.9.33.2/stamp/.package_compile] Error 2
make[1]: Leaving directory `/home/michael/Documents/openwrt/openwrt'
make: *** [world] Error 2

I have tried adding

+libc

to the DEPENDS section, but that doesn't do it. And there are no " .provides " files in

staging_dir/<target_arch>/pkginfo/

which provide for libc.so.6, only libc.so.0.


Somebody must have some sort of idea why this is happening...

This is an indication that your binary was not cross compiled at all but built using your systems native compiler.
The "libc.so.6" file usually belongs to glibc.

Do you have any idea why this might happen or how to further diagnose the issue?

Usually due to broken Makefiles, e.g. ones that hardcode essential variables, like "CC=gcc"

Here is a link to the applications native Makefile.

Here is a link to the OpenWRT Makefile, can you see anything that might cause this to happen?

Thanks for the help, I'm going a little bit insane trying to fix this

Post the output of make package/amld/{clean,compile} V=99

make[3]: Nothing to be done for `all'.

Is your src/ directory actually clean? I suspect it contains an "amldmonitor" executable already which was built for your host.
Make sure your src/ directory does not contain any junk like *.o files or final executables.

You are 100% correct, thank you very much!

If you want to post that as an answer on the unix stackexchange I will happily accept it.

Seriously though, I owe you one!

i think i found the solution to this problem. you need to choose libstdcpp lib in the "base system" when you build the SDK

The solution provided above (addinglibstdcpp to the Makefile as dependency) results the same.

jow wrote:

make[3]: Nothing to be done for `all'.

Is your src/ directory actually clean? I suspect it contains an "amldmonitor" executable already which was built for your host.
Make sure your src/ directory does not contain any junk like *.o files or final executables.

Any solution of Makefile mod if copying final executables is needed?

The discussion might have continued from here.