Dependency issue when adding new package

I try to follow the topic to add Hello World package. But in the Migrating to use GNU make in your application topic, there is a dependency issue when I use Make to build the package.

The error message is follow:

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

Has anyone encountered the same problem?

libc.so.6 is the current soname of GNU libc, means your executable likely wasn't cross compiled but built for the host. This can either happen when your Makefile uses the wrong gcc, or - which is more likely when sticking to the examples - your C source directory is not clean and already contains precompiled object files or final executables made for the host.

Make sure that your source directory is clean and contains only *.c, *.h etc. files and no *.o ones or ELF executables.

1 Like

I'm sure that my source directory is clean and only have helloworld.c and Makefile in the folder.
I try to find solution on internet, once I add '$(CP) /lib/x86_64-linux-gnu/libc.so.6 $(1)/usr/bin' in the Package install instructions. It can be compiled successfully, but the package not work when I install in openwrt.

The please provide the actual OpenWrt Makefile and - if applicable - the inner Makefile as well here. It seems to me that you're using the wrong compiler for building your sources.

I don't modify the OpenWrt Make file, and the helloworld Make file is follow the guide. I share the Makefile on dropbox, please help to check, thanks.
OpenWrt Makefile: https://www.dropbox.com/s/26b12d0ylr5pc7u/Makefile_openwrt?dl=0
Helloword Makefile: https://www.dropbox.com/s/cpgbco0f5bcqul1/Makefile_helloworld?dl=0

Your helloworld Makefile is broken. You need to change

define Build/Compile
	$(MAKE) -C $(PKG_BUILD_DIR)
	CC="$(TARGET_CC)" 
	CFLAGS="$(TARGET_CFLAGS)"  
	LDFLAGS="$(TARGET_LDFLAGS)"
endef

into

define Build/Compile
	$(MAKE) -C $(PKG_BUILD_DIR) \
		CC="$(TARGET_CC)" \
		CFLAGS="$(TARGET_CFLAGS)" \
		LDFLAGS="$(TARGET_LDFLAGS)"
endef

Note the line continuation (\) character at the end which forces the CC, CFLAGS and LDFLAGS assignments to be part of the $(MAKE) command.

1 Like

After change to you solution, there is another error

i486-openwrt-linux-musl-gcc: fatal error: no input files

It seems directory error...
But I try to use original method, It can build succeed.

define Build/Compile
$(TARGET_CC) $(TARGET_CFLAGS) -o $(PKG_BUILD_DIR)/helloworld.o -c $(PKG_BUILD_DIR)/helloworld.c
$(TARGET_CC) $(TARGET_LDFLAGS) -o $(PKG_BUILD_DIR)/$1 $(PKG_BUILD_DIR)/helloworld.o
endef

I had the exact issue, after I re-edited the compile part of Makefile, it worked for me by issue: make -j1 package/helloworld/{clean,compile}:

define Build/Compile
$(MAKE) -C $(PKG_BUILD_DIR) CC="$(TARGET_CC)" CFLAGS="$(TARGET_CFLAGS)" LDFLAGS="$(TARGET_LDFLAGS)"
endef

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.