title: Cannot compile package Helloworld on C++ for OpenWrt
body: <p>I'm trying to compile simple helloworld program for OpenWrt (using build system, branch 17.01.6). I used two tutorials: <a href="https://openwrt.org/docs/guide-developer/helloworld/start" rel="nofollow noreferrer">helloworld tutorial on official site</a> and <a href="https://www.gargoyle-router.com/old-openwrt-coding.html" rel="nofollow noreferrer">by Eric Bishop</a>, part 2 for C++.</p>
  
  <p>But during compiling helloworld-package I got error: <code>Package helloworld is missing dependencies for the following libraries:
  libc.so.6</code></p>
  
  <p>Structure of files:<br/>
  .<br/>
  ├--openwrt_17_01<br/>
  &nbsp;&nbsp;&nbsp;&nbsp;├--source #source directory, build system<br/>
  &nbsp;&nbsp;&nbsp;&nbsp;├--helloworld #helloworld project<br/>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;└--src<br/>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;├--helloworld.cpp<br/>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;└--Makefile #C++ project makefile<br/>
  &nbsp;&nbsp;&nbsp;&nbsp;└--mypackages<br/>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;└--examples<br/>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;└--helloworld<br/>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;└--Makefile #package makefile<br/></p>
  
  <p>openwrt_17_01/helloworld/src/helloworld.cpp:</p>
  
  <pre><code>#include "stdio.h"
  int main()
  {
      printf("Hello, world! (C++)\n\n");
      return 0;
  }
  </code></pre>
  
  <p>openwrt_17_01/helloworld/src/Makefile:</p>
  
  <pre><code>helloworld: helloworld.o
      $(CXX) $(LDFLAGS) helloworld.o -o helloworld $(LIBS)
  helloworld.o: helloworld.cpp
      $(CXX) $(CXXFLAGS) -c helloworld.cpp
  clean:
      rm *.o helloworld
  </code></pre>
  
  <p>mypackages/examples/helloworld/Makefile:</p>
  
  <pre><code>include $(TOPDIR)/rules.mk
  
  PKG_NAME:=helloworld
  PKG_VERSION:=1.0
  PKG_RELEASE:=1
  
  SOURCE_DIR:=/home/mzhi/proj_src/openwrt_17_01/helloworld
  PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
  
  include $(INCLUDE_DIR)/package.mk
  
  define Package/helloworld
      SECTION:=examples
      DEPENDS:= +libstdcpp +libc
      CATEGORY:=Examples
      TITLE:=Hello, World!
  endef
  
  define Package/helloworld/description
      A simple "Hello, world!" -application.
  endef
  
  define Build/Prepare
      mkdir -p $(PKG_BUILD_DIR)
      $(CP) $(SOURCE_DIR)/src/* $(PKG_BUILD_DIR)/
  endef
  
  define Build/Compile
      $(MAKE) -C $(PKG_BUILD_DIR) \
      LIBS="-nodefaultlibs -lgcc -lc -luClibc++" \
      LDFLAGS="$(EXTRA_LDFLAGS)" \
      CXXFLAGS="$(TARGET_CFLAGS) $(EXTRA_CPPFLAGS) -nostdinc++" \
      $(TARGET_CONFIGURE_OPTS) \
      CROSS="$(TARGET_CROSS)" \
      ARCH="$(ARCH)" \
      $(1);
  endef
  
  define Package/helloworld/install
      $(INSTALL_DIR) $(1)/usr/bin
      $(INSTALL_BIN) $(PKG_BUILD_DIR)/helloworld $(1)/usr/bin
  endef
  
  $(eval $(call BuildPackage,helloworld))
  </code></pre>
  
  <p>Full output of compilation (make package/helloworld/compile -j1 V=s):</p>
  
  <pre><code>make[1]: Entering directory 
  '/home/mzhi/proj_src/openwrt_17_01/openwrt'
  make[2]: Entering directory 
  '/home/mzhi/proj_src/openwrt_17_01/openwrt/package/libs/toolchain'
  if [ -f /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target- mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean ]; then rm -f /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean; fi
  echo "libc" &gt;&gt; 
  /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install
  if [ -f /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean ]; then rm -f /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean; fi
  echo "libgcc" &gt;&gt; 
  /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install
  if [ -f /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean ]; then rm -f /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean; fi
  if [ -f /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean ]; then rm -f /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean; fi
  if [ -f /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean ]; then rm -f /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean; fi
  echo "libstdcpp" &gt;&gt; 
  /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install
  if [ -f /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean ]; then rm -f /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean; fi
  echo "libpthread" &gt;&gt; 
  /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install
  if [ -f /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean ]; then rm -f /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean; fi
  if [ -f /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean ]; then rm -f /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean; fi
  echo "librt" &gt;&gt; 
  /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install
  if [ -f /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean ]; then rm -f /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean; fi
  if [ -f /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean ]; then rm -f /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean; fi
  if [ -f /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean ]; then rm -f /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean; fi
  make[2]: Leaving directory '/home/mzhi/proj_src/openwrt_17_01/openwrt/package/libs/toolchain'
  make[2]: Entering directory '/home/mzhi/proj_src/openwrt_17_01/mypackages/examples/helloworld'
  mkdir -p /home/mzhi/proj_src/openwrt_17_01/openwrt/bin/targets/ramips/mt7621/packages /home/mzhi/proj_src/openwrt_17_01/openwrt/build_dir/target-mipsel_24kc_musl-1.1.16/helloworld/ipkg-mipsel_24kc/helloworld/CONTROL /home/mzhi/proj_src/openwrt_17_01/openwrt/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo
  install -d -m0755 /home/mzhi/proj_src/openwrt_17_01/openwrt/build_dir/target-mipsel_24kc_musl-1.1.16/helloworld/ipkg-mipsel_24kc/helloworld/usr/bin
  install -m0755 /home/mzhi/proj_src/openwrt_17_01/openwrt/build_dir/target-mipsel_24kc_musl-1.1.16/helloworld/helloworld /home/mzhi/proj_src/openwrt_17_01/openwrt/build_dir/target-mipsel_24kc_musl-1.1.16/helloworld/ipkg-mipsel_24kc/helloworld/usr/bin
  find /home/mzhi/proj_src/openwrt_17_01/openwrt/build_dir/target-mipsel_24kc_musl-1.1.16/helloworld/ipkg-mipsel_24kc/helloworld -name 'CVS' -o -name '.svn' -o -name '.#*' -o -name '*~'| xargs -r rm -rf
  Package helloworld is missing dependencies for the following libraries:
  libc.so.6
  Makefile:65: recipe for target '/home/mzhi/proj_src/openwrt_17_01/openwrt/bin/packages/mipsel_24kc/mypackages/helloworld_1.0-1_mipsel_24kc.ipk' failed
  make[2]: *** [/home/mzhi/proj_src/openwrt_17_01/openwrt/bin/packages/mipsel_24kc/mypackages/helloworld_1.0-1_mipsel_24kc.ipk] Error 1
  make[2]: Leaving directory '/home/mzhi/proj_src/openwrt_17_01/mypackages/examples/helloworld'
  package/Makefile:105: recipe for target 'package/feeds/mypackages/helloworld/compile' failed
  make[1]: *** [package/feeds/mypackages/helloworld/compile] Error 2
  make[1]: Leaving directory '/home/mzhi/proj_src/openwrt_17_01/openwrt'
  /home/mzhi/proj_src/openwrt_17_01/openwrt/include/toplevel.mk:205: recipe for target 'package/helloworld/compile' failed
  make: *** [package/helloworld/compile] Error 2
  </code></pre>
  
  <p>operating system: ubuntu 16.04<br/>
  Target System: Mediatek Ralink MIPS<br/>
  Subtarget: MT7621 based boards<br/>
  Target Profile: Ubiquiti EdgeRouter X<br/></p>
  
  <p>Googled a lot, but I still can not understand why the compiler does not see the necessary library libc.so.6 and how to connect it correctly in the Makefile</p>
  
  <p>Maybe someone has already faced similar problems, please share the solution.</p>