Search code examples
makefiledependenciesopenwrt

How can I link to other package's object files in OpenWRT?


I have a package in OpenWRT which depends on another package. My code needs to link to an object file (.o) created by the other package. What is the general way to accomplish this?

My code is in c, and compiles to an object file correctly. However, I'm failing at the linking step when creating an executable. Apologies for not being able to post Makefiles. That is not allowed by workplace policy.


Solution

  • Normally you would use a .a or .so file for this, but it should be possible to do. You could install the .o file in the InstallDev part of the openwrt Makefile.

    define Build/InstallDev
        $(INSTALL_DIR) $(1)/usr/lib/
        $(INSTALL_BIN) $(PKG_BUILD_DIR)/foo.o $(1)/usr/lib
    

    By installing it in InstallDev it is placed in the staging_dir and not installed on the device.

    Then add use this file in the pakcage Makefile

    PKG_BUILD_DEPENDS= foo-package