OpenWrt Forum Archive

Topic: error -ash: helloworld: not found

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

Hello! I try to build helloworld programm for openwrt, router Tp-link wr740n, firmware openwrt ar71xx v4.
I build package, load it on router via ftp and install. When i try to run programm, i get error:

root@OpenWrt:/bin# helloworld
-ash: helloworld: not found

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
endef
define Package/helloworld/description
    helloworld packadetest
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 in src folder:

helloworld: helloworld.o
    $(CC) $(LDFLAGS) helloworld.o -o helloworld

helloworld.o: helloworld.c
    $(CC) $(CFLAGS) -c helloworld.c

clean:
    rm *.o helloworld

source:

#include <stdio.h>
int main(void)
{
printf("hello world!\n");
return 0;
}

make was succesfully, *.ipk generated in /bin/package/base. but installation returned errors:

root@OpenWrt:~# opkg install helloworld_1_ar71xx.ipk
Installing helloworld (1) to root...
Configuring helloworld.
//usr/lib/opkg/info/helloworld.postinst: line 4: default_postinst: not found
Collected errors:
 * pkg_run_script: package "helloworld" postinst script returned status 127.
 * opkg_configure: helloworld.postinst returned 127.

Despite this, binary was placed in /bin folder, but i can't execute it.
What could be the problem?

What happens if you execute the program in its full path, i.e. /bin/helloworld, etc.?

problem solved: program use musl C library, but firmware contains uLibc only.
I build firmware from trunk, what using musl as standart C library and install on router.
program print string "Hello world!":

root@OpenWrt:~# helloworld
hello world!

Also installation  of package has no errors.

The discussion might have continued from here.