OpenWrt Forum Archive

Topic: Simple hello world program error

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

I am trying to learn OpenWRT.
I have downloaded the sdk.
Created a simple helloworld.cpp file inside the packages\helloworld folder
created the following Makefile inside the packages\helloworld

======================Makefile==================================
include $(TOPDIR)/rules.mk

PKG_NAME:=helloworld
PKG_RELEASE:=1

PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)


include $(INCLUDE_DIR)/package.mk

define Package/helloworld
    SECTION:=utils
    CATEGORY:=Utilities
    TITLE:=Helloworld -- prints a snarky message
    Package/PKG_NAME/description:=\
    If you can't figure out what this program does, \\\
    you're probably brain-dead and need immediate \\\
    medical attention.
endef

define Build/Prepare
    mkdir -p $(PKG_BUILD_DIR)
    $(CP) ./src/* $(PKG_BUILD_DIR)/
endef

define Package/helloworld/install
    $(INSTALL_DIR) $(1)/bin
    $(INSTALL_BIN) $(PKG_BUILD_DIR)/helloworld $(1)/bin/
endef

$(eval $(call BuildPackage,helloworld))
======================Makefile==================================

After that I ran make command from the sdk root

I am getting the following error

naro_uClibc-0.9.33.2$ make V=s
make[1]: Entering directory '/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2'
make[2]: Entering directory '/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2'
make[3]: Entering directory '/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/package/helloworld'
CFLAGS="-O2 -pipe -march=i486 -fno-caller-saves -fhonour-copts -Wno-error=unused-but-set-variable  -I/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/target-i386_uClibc-0.9.33.2/usr/include -I/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/target-i386_uClibc-0.9.33.2/include -I/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/toolchain-i386_gcc-4.6-linaro_uClibc-0.9.33.2/usr/include -I/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/toolchain-i386_gcc-4.6-linaro_uClibc-0.9.33.2/include " CXXFLAGS="-O2 -pipe -march=i486 -fno-caller-saves -fhonour-copts -Wno-error=unused-but-set-variable  -I/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/target-i386_uClibc-0.9.33.2/usr/include -I/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/target-i386_uClibc-0.9.33.2/include -I/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/toolchain-i386_gcc-4.6-linaro_uClibc-0.9.33.2/usr/include -I/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/toolchain-i386_gcc-4.6-linaro_uClibc-0.9.33.2/include " LDFLAGS="-L/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/target-i386_uClibc-0.9.33.2/usr/lib -L/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/target-i386_uClibc-0.9.33.2/lib -L/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/toolchain-i386_gcc-4.6-linaro_uClibc-0.9.33.2/usr/lib -L/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/toolchain-i386_gcc-4.6-linaro_uClibc-0.9.33.2/lib " make -j1 -C /home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/build_dir/target-i386_uClibc-0.9.33.2/helloworld/. AR=i486-openwrt-linux-uclibc-ar AS="ccache_cc -c -O2 -pipe -march=i486 -fno-caller-saves -fhonour-copts -Wno-error=unused-but-set-variable" LD=i486-openwrt-linux-uclibc-ld NM=i486-openwrt-linux-uclibc-nm CC="ccache_cc" GCC="ccache_cc" CXX="ccache_cxx" RANLIB=i486-openwrt-linux-uclibc-ranlib STRIP=i486-openwrt-linux-uclibc-strip OBJCOPY=i486-openwrt-linux-uclibc-objcopy OBJDUMP=i486-openwrt-linux-uclibc-objdump SIZE=i486-openwrt-linux-uclibc-size CROSS="i486-openwrt-linux-uclibc-" ARCH="i386" ;
make[4]: Entering directory '/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/build_dir/target-i386_uClibc-0.9.33.2/helloworld'
make[4]: *** Notargets specified and no makefile found.  Stop.
make[4]: Leaving directory '/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/build_dir/target-i386_uClibc-0.9.33.2/helloworld'
Makefile:32: recipe for target '/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/build_dir/target-i386_uClibc-0.9.33.2/helloworld/.built' failed
make[3]: *** [/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/build_dir/target-i386_uClibc-0.9.33.2/helloworld/.built] Error 2
make[3]: Leaving directory '/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/package/helloworld'
package/Makefile:105: recipe for target 'package/helloworld/compile' failed
make[2]: *** [package/helloworld/compile] Error 2
make[2]: Leaving directory '/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2'
package/Makefile:101: recipe for target '/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/target-i386_uClibc-0.9.33.2/stamp/.package_compile' failed
make[1]: *** [/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/target-i386_uClibc-0.9.33.2/stamp/.package_compile] Error 2
make[1]: Leaving directory '/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2'
/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/include/toplevel.mk:144: recipe for target 'world' failed
make: *** [world] Error 2

Can anyone please help me to find out what is the error?

(Last edited by sukesh.chand on 15 Nov 2017, 18:50)

Although it won't immediately solve your problem, I recommend you check the "Hello, world!" article series for LEDE. The build system is almost the same. The series gives you a good overview on how to build stuff.

https://lede-project.org/docs/guide-dev … orld/start

Hi,
Thanks for the replay.

I have tried the build system from the above link, it has so many steps to configure. I am bit confused.

Actually I have downloaded pre build sdk (OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2) from the downloads.openwrt.org and trying to build. then the above error is happening.

Can you able to tell me why the following error is related to.
make[4]: *** Notargets specified and no makefile found.  Stop.

The discussion might have continued from here.