Cross Compiling GRPC for MIPS architecture for OpenWrt

Hi Folks,

This is my first time cross compiling, of any software, GRPC. I have followed the instructions in the MakeFile of GRPC fro cross compiling

Below are the series of commands I have followed to execute

  1. export STAGING_DIR=~/Documents/openwrt/staging_dir/toolchain-mips_24kc_gcc-7.3.0_musl

  2. export PATH=$PATH:$STAGING_DIR/bin

  3. make HAS_PKG_CONFIG=false CC=mips-openwrt-linux-gcc CXX=mips-openwrt-linux-g++ LD=mips-openwrt-linux-ld LDXX=mips-openwrt-linux-g++ AR=mips-openwrt-linux-gcc-ar STRIP=mips-openwrt-linux-strip PROTOBUF_CONFIG_OPTS="--host=mips-linux --with-protoc=/usr/local/bin/protoc" GRPC_CROSS_COMPILE=true GRPC_CROSS_LDOPTS="-L$STAGING_DIR/lib -L$STAGING_DIR/lib32 -L$STAGING_DIR/lib64" GRPC_CROSS_AROPTS="--target=elf32-little"

I am facing the below error

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/' failed
make: *** [~/Documents/grpc_cross/grpc/libs/opt/] Error 1

Any help would be appreciated


The normal way is to create a openwrt compatible package file and let the default sdk build the package.


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

$(INSTALL_BIN) $(PKG_BUILD_DIR)/ $(1)/usr/lib/
$(INSTALL_BIN) $(PKG_BUILD_DIR)/ $(1)/usr/lib/

These shared libraries I need to generate from cross compilation which is where I am facing these errors.

Please mention if there is any other method to generate and link these cross compiled libraries.


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)/


include $(INCLUDE_DIR)/

define Package/grpc-agent
   TITLE:=IPC library using mqtt
   DEPENDS:=+libstdcpp +libpthread +libopenssl +lib-ipc

define Package/grpc-agent/description
  GRPC server utility.
  Used for communicating between processes.

include $(INCLUDE_DIR)/

# 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)

define Build/Install

define Package/grpc-agent/install
	$(INSTALL_DIR) $(1)/usr/lib
	$(INSTALL_DIR) $(1)/usr/bin
	$(INSTALL_BIN) $(PKG_BUILD_DIR)/ $(1)/usr/lib/
	$(INSTALL_BIN) $(PKG_BUILD_DIR)/ $(1)/usr/lib/
	$(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

define Package/lib-ipc/config

$(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 and

For ARM architecture, we have cross compiled the grpc package (with similar make command mentioned in the question) and generated the libraries successfully ( and )

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.

Hope I am clear now.


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.

Hi Karra,

Were you able to succeed in creating gRPC package for openwrt?
Even I am looking for similar package to create one for openwrt based environment.

Punith Kumar