mips-openwrt-linux-ld: unrecognized option '-pthread'
mips-openwrt-linux-ld: use the --help option for usage information
Makefile:3204: recipe for target '~/Documents/grpc_cross/grpc/libs/opt/libaddress_sorting.so.7.0.0' failed
make: *** [~/Documents/grpc_cross/grpc/libs/opt/libaddress_sorting.so.7.0.0] Error 1
If I understand it correctly, you are mentioning about package which contains a Makefile and set of other files and when run with make command it creates as ipk package to install.
I already have that file but the way we are doing it is, it requires some shared libraries for the specific architecture like
Not sure what you mean?
If your openwrt package needs specific libs you can add them as dependencies and they will be build for your target. If the lib does not yet exist in the openwrt package repo, you also need to create a makefile for this new lib, so you can add it correctly as dependency.
Maybe post the openwrt makefile of the package you want to create and what lib dependencies you have problems with.
include $(TOPDIR)/rules.mk
PKG_NAME:=grpc-agent
PKG_VERSION:=1
PKG_RELEASE:=0.1
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
include $(INCLUDE_DIR)/package.mk
define Package/grpc-agent
SECTION:=base
CATEGORY:=Packages
TITLE:=IPC library using mqtt
DEPENDS:=+libstdcpp +libpthread +libopenssl +lib-ipc
DEFAULT:=n
endef
define Package/grpc-agent/description
GRPC server utility.
Used for communicating between processes.
endef
include $(INCLUDE_DIR)/cmake.mk
CMAKE_SOURCE_DIR=$(CONFIG_IOT_APPLICATIONS_SOURCE_DIRECTORY)/build
CMAKE_OPTIONS+="-DGRPC_SERVICE=TRUE"
CMAKE_OPTIONS+="-DLEDE_BUILDROOT=TRUE"
# Clean left-over binaries in source-dir before
# building.
define Build/Configure
$(call Build/Configure/Default)
$(MAKE) -C $(PKG_BUILD_DIR) distclean
$(call Build/Configure/Default)
endef
define Build/Install
endef
define Package/grpc-agent/install
$(INSTALL_DIR) $(1)/usr/lib
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/libgrpc++.so.1 $(1)/usr/lib/libgrpc++.so.1
$(INSTALL_BIN) $(PKG_BUILD_DIR)/libgrpc.so.4 $(1)/usr/lib/libgrpc.so.4
$(INSTALL_BIN) $(PKG_BUILD_DIR)/grpcService $(1)/usr/bin/grpcService
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) files/grpcservice.initd $(1)/etc/init.d/grpcservice
endef
define Package/lib-ipc/config
endef
$(eval $(call BuildPackage,grpc-agent))
this is the make file I am using for grpc package on openWRT. For this to compile successfully, I need two libraries libgrpc++.so.1 and libgrpc.so.4.
For ARM architecture, we have cross compiled the grpc package (with similar make command mentioned in the question) and generated the libraries successfully (libgrpc++.so.1 and libgrpc.so.4 )
Now we are using MIPS architecture (AR7XXX/AR9XXX) board. So we would like to cross compile grpc for this architecture and generate the necessary libraries so that we can refer in the above make file.
So when I am trying to cross compile for MIPS, this is where I am getting stuck, facing errors as mentioned in the question.
I assume this has been done via some custom/manual steps or we would not have this conversation.
If your package grpc-agent is dependent on libgrpc than yes you need to create a separate openwrt makefile that builds and installs the lib, so it can be added similar to all the other libs: DEPENDS:=+libstdcpp +libpthread +libopenssl +lib-ipc +libgrpc
I'm also not sure where lib-ipc is coming from, cant find it in our repos, so not sure if this lib is supposed to depend and build libgrpc.
Check my libmill as a simple and straight forward example of a openwrt lib makefile.
PS: Pay attention to Build/InstallDev those files (headers, static libs, package config) will be installed into staging, so other packages get all the needed stuff during build, while Package/libmill/install is where the actual shared libs are installed for the build target.