首先到官网下载libiec61850源码libiec61850-1.5.0.tar.gzlibIEC61850 / lib60870 | open source libraries for IEC 61850 and IEC 60870-5-101/104
在openwrt//package/libs/目录下创建libiec61850文件夹并把libiec61850-1.5.0.tar.gz解压到该文件夹下。为了让openwrt能够识别编译,还需要在libiec61850文件夹创建一个Makefile:
include $(TOPDIR)/rules.mk
PKG_NAME:=libiec61850
PKG_VERSION:=0.10.0
PKG_RELEASE:=1
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
PKG_INSTALL:=1
include $(INCLUDE_DIR)/package.mk
define Package/libiec61850
SECTION:=libs
CATEGORY:=Libraries
SUBMENU:=iec61850
TITLE:=iec61850
endef
define Package/libiec61850/description
iec61850
endef
define Build/InstallDev
$(INSTALL_DIR) $(1)/usr/lib
endef
define Package/libiec61850/install
$(INSTALL_DIR) $(1)/usr/lib
endef
$(eval $(call BuildPackage,${PKG_NAME}))
现在就可以在openwrt编译菜单里可以找到该库的菜单
选中后保存配置并退出,但是现在还不能编译,否则会出现'-Wformat-security' ignored without '-Wformat' [-Werror=format-security]的错误!!
打开libiec61850-1.5.0目录下的Makefile文件,添加CFLAGS += -Wformat
保存后回到openwrt目录下执行sudo make V=s 完成后会在openwrt/build_dir/target-mipsel_24kc_musl/libiec61850/build-mipsel/目录下生成一个libiec61850.a库文件,包含相关的头文件后就可以在我们的工程里调用了。