SDk编译时需要-lsqlite3 -lcurl -lpthread,需要的头文件如下:
- cc=/home/qx/xiaojunyu/openwrt-14.07/build_dir/target-mips_34kc_uClibc-0.9.33.2/OpenWrt-SDK-ar71xx-for-linux-x86_64-gcc-4.8-linaro_uClibc-0.9.33.2/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/bin/mips-openwrt-linux-gcc
- xiao:xiao.o
- $(cc)-oxiaoxiao.o-lpthread-lcurl-lsqlite3
- xiao.o:xiao.c
- $(cc)-cxiao.c
- clean:
- rm-fxiaoxiao.o</span>
- include$(TOPDIR)/rules.mk
- PKG_NAME:=xiao
- PKG_RELEASE:=1
- PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
- include$(INCLUDE_DIR)/package.mk
- definePackage/xiao
- SECTION:=utils
- CATEGORY:=Utilities
- TITLE:=my_module--mac_scan
- DEPENDS:=+libsqlite3+libcurl+libpthread+libc
- endef
- definePackage/xiao/description
- endef
- defineBuild/Prepare
- echo"HereisPackage/Prepare"
- mkdir-p$(PKG_BUILD_DIR)
- $(CP)./src/*$(PKG_BUILD_DIR)/
- endef
- definePackage/xiao/install
- echo"HereisPackage/install"
- $(INSTALL_DIR)$(1)/bin
- $(INSTALL_BIN)$(PKG_BUILD_DIR)/xiao$(1)/bin/
- endef
- $(eval$(callBuildPackage,xiao))</span>
文件目录结构为:
xiao{Makefile src{xiao.c Makefilr}} 放在SDK目录的package下。
首先进入主目录,比如openwrt,然后sdk的目录应该在
- openwrt-14.07/build_dir/target-mips_34kc_uClibc-0.9.33.2/OpenWrt-SDK-ar71xx-for-linux-x86_64-gcc-4.8-linaro_uClibc-0.9.33.2
在openwet目录,具体看你创建的目录下,make menuconfig 在library下找到你需要编译的库,比如我需要libsqlit3,libcurl,libpthread,选中以后保存编译,编译完成后,把package包复制到sdk目录下。
然后,package包的第一层Makefile中加入
- +libsqlite3+libcurl+libpthread+libc
退到sdk主目录,运行make package/xiao/compile V=s即可完成编译,或者直接make全部编译。 原文链接:https://www.f2er.com/javaschema/284229.html