2.交叉编译器及版本信息
mipsel-linux + buildroot-gcc463_32bits.tar.bz23.创建工作目录
lancer@ubuntu:~$ mkdir -p tr069/usrlancer@ubuntu:~/tr069/usr$ pwd
/home/lancer/tr069/usr4.移植json-c -----------------------------------------------------------------------------------------------
root@ubuntu:/home/lancer/tr069# git clone git://github.com/json-c/json-c.gitcd json-cGenerate configuration files:
# sh autogen.shConfigure:
# ./configure --prefix=/home/lancer/tr069/usr --host=mipsel-linux# make
# make install# ln -sf /home/lancer/tr069/usr/include/json-c /usr/include/json5.移植libubox ----------------------------------------------------------------------------------------------
root@ubuntu:/home/lancer/tr069# git clone git://nbd.name/luci2/libubox.gitcd libuboxConfigure:
vim CMakeLists.txt #在前边添加如下配置,注意是最前边SET(CMAKE_SYSTEM_NAME Linux)SET(CMAKE_C_COMPILER "mipsel-linux-gcc")SET(CMAKE_CXX_COMPILER "mipsel-linux-g++")INCLUDE_DIRECTORIES("/home/lancer/tr069/usr/include/")INCLUDE_DIRECTORIES("/home/lancer/tr069/usr/include/json-c")LINK_DIRECTORIES("/home/lancer/tr069/usr/lib")(cmake如何清除编译缓存,root@ubuntu:/home/lancer/tr069/libubox# rm CMakeCache.txt)
root@ubuntu:/home/lancer/tr069/libubox# cmake CMakeLists.txt -DBUILD_LUA=OFF -DCMAKE_INSTALL_PREFIX=/home/lancer/tr069/usr-- The C compiler identification is GNU-- Check for working C compiler: /opt/buildroot-gcc463/usr/bin/mipsel-linux-cc-- Check for working C compiler: /opt/buildroot-gcc463/usr/bin/mipsel-linux-cc -- works #说明添加OKBuild:
root@ubuntu:/home/lancer/tr069/libubox# makeScanning dependencies of target ubox[ 3%] Building C object CMakeFiles/ubox.dir/avl.c.o[ 6%] Building C object CMakeFiles/ubox.dir/avl-cmp.c.o[ 9%] Building C object CMakeFiles/ubox.dir/blob.c.o[ 12%] Building C object CMakeFiles/ubox.dir/blobmsg.c.o[ 16%] Building C object CMakeFiles/ubox.dir/uloop.c.o[ 19%] Building C object CMakeFiles/ubox.dir/usock.c.o[ 22%] Building C object CMakeFiles/ubox.dir/ustream.c.o[ 25%] Building C object CMakeFiles/ubox.dir/ustream-fd.c.o[ 29%] Building C object CMakeFiles/ubox.dir/vlist.c.o[ 32%] Building C object CMakeFiles/ubox.dir/utils.c.o[ 35%] Building C object CMakeFiles/ubox.dir/safe_list.c.o[ 38%] Building C object CMakeFiles/ubox.dir/runqueue.c.o[ 41%] Building C object CMakeFiles/ubox.dir/md5.c.o[ 45%] Building C object CMakeFiles/ubox.dir/ulog.c.oLinking C shared library libubox.so[ 45%] Built target uboxScanning dependencies of target blobmsg_json[ 48%] Building C object CMakeFiles/blobmsg_json.dir/blobmsg_json.c.oIn file included from /home/lancer/tr069/libubox/blobmsg_json.c:17:0:/home/lancer/tr069/libubox/blobmsg_json.h:22:24: fatal error: json/json.h: No such file or directorycompilation terminated.make[2]: *** [CMakeFiles/blobmsg_json.dir/blobmsg_json.c.o] Error 1make[1]: *** [CMakeFiles/blobmsg_json.dir/all] Error 2make: *** [all] Error 2解决方案:我们前边已经包含了头文件路径,"/home/lancer/tr069/usr/include/json-c",把所有"json/json.h",改为"json.h"再重新编译/home/lancer/tr069/libubox/blobmsg_json.c: In function '__blobmsg_add_json':/home/lancer/tr069/libubox/blobmsg_json.c:78:2: error: implicit declaration of function 'is_error' [-Werror=implicit-function-declaration]cc1: all warnings being treated as errorsmake[2]: *** [CMakeFiles/blobmsg_json.dir/blobmsg_json.c.o] Error 1make[1]: *** [CMakeFiles/blobmsg_json.dir/all] Error 2make: *** [all] Error 2解决方案:vim blobmsg_json.c +78添加头文件#include "bits.h"重新编译OKInstall:
sudo make installsudo ln -sf /usr/local/lib/libubox.so /usr/lib/libubox.sosudo mkdir -p /usr/share/libuboxsudo ln -sf /usr/local/share/libubox/jshn.sh /usr/share/libubox/jshn.sh6.移植uci--------------------------------------------------------------------------------------------------
Get the sources:lancer@ubuntu:~/tr069$ git clone git://nbd.name/uci.gitcd uciConfigure:
vim CMakeLists.txt #在前边添加如下配置,注意是最前边SET(CMAKE_SYSTEM_NAME Linux)SET(CMAKE_C_COMPILER "mipsel-linux-gcc")SET(CMAKE_CXX_COMPILER "mipsel-linux-g++")INCLUDE_DIRECTORIES("/home/lancer/tr069/usr/include/")LINK_DIRECTORIES("/home/lancer/tr069/usr/lib")root@ubuntu:/home/lancer/tr069/uci# cmake CMakeLists.txt -DBUILD_LUA=OFF -DCMAKE_INSTALL_PREFIX=/home/lancer/tr069/usr2Build:
makeInstall:
class="western"sudo make installsudo ln -sf /usr/local/bin/uci /sbin/ucisudo ln -sf /usr/local/lib/libuci.so /usr/lib/libuci.so7.移植ubus-------------------------------------------------------------------------------------------------
Get the sources:root@ubuntu:/home/lancer/tr069# git clone git://nbd.name/luci2/ubus.gitcd ubusConfigure:
vim CMakeLists.txt #在前边添加如下配置,注意是最前边SET(CMAKE_SYSTEM_NAME Linux)SET(CMAKE_C_COMPILER "mipsel-linux-gcc")SET(CMAKE_CXX_COMPILER "mipsel-linux-g++")INCLUDE_DIRECTORIES("/home/lancer/tr069/usr/include/")INCLUDE_DIRECTORIES("/home/lancer/tr069/usr/include/json-c")LINK_DIRECTORIES("/home/lancer/tr069/usr/lib")root@ubuntu:/home/lancer/tr069/ubus# cmake CMakeLists.txt -DBUILD_LUA=OFF -DCMAKE_INSTALL_PREFIX=/home/lancer/tr069/usrBuild:
makeInstall:
sudo make installsudo ln -sf /usr/local/sbin/ubusd /usr/sbin/ubusdsudo ln -sf /usr/local/lib/libubus.so /usr/lib/libubus.so8.移植microxml---------------------------------------------------------------------------------------------
Get the sources:root@ubuntu:/home/lancer/tr069# git clone https://github.com/pivasoftware/microxml.gitcd microxmlGenerate configuration files:
root@ubuntu:/home/lancer/tr069/microxml# autoconf -iConfigure:
root@ubuntu:/home/lancer/tr069/microxml# ./configure --prefix=/home/lancer/tr069/usr --host=mipsel-linux --enable-threads --enable-shared --enable-staticBuild:
makeInstall:
sudo make installsudo ln -sf /usr/lib/libmicroxml.so.1.0 /lib/libmicroxml.sosudo ln -sf /usr/lib/libmicroxml.so.1.0 /lib/libmicroxml.so.19.移植curl
下载:https://curl.haxx.se/download.html :curl-7.53.1.tar.gzcd curl-7.53.1Configure:
root@ubuntu:/home/lancer/tr069/curl-7.53.1# ./configure --prefix=/home/lancer/tr069/usr --host=mipsel-linuxBuild:
makeInstall:
sudo make install10.移植easycwmp-----------------------------------------------------------------------------------------------
官网下载:http://www.easycwmp.org/download.html : 我选择easycwmp-1.5.2.tar.gzcd easycwmp-1.5.2Generate configuration files:
root@ubuntu:/home/lancer/tr069/easycwmp-1.5.2# autoreconf -iConfigure:
./configure --prefix=/home/lancer/tr069/usr --host=mipsel-linux --enable-debug --enable-devel --enable-acs=multi --enable-jsonc=1 --x-includes=/home/lancer/tr069/usr/include/ --x-libraries=-L/home/lancer/tr069/usr/lib......checking for LIBCURL... noconfigure: error: Package requirements (libcurl) were not met:Package libcurl was not found in the pkg-config search path.
Perhaps you should add the directory containing `libcurl.pc'to the PKG_CONFIG_PATH environment variableNo package 'libcurl' foundConsider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.Alternatively, you may set the environment variables LIBCURL_CFLAGS
and LIBCURL_LIBS to avoid the need to call pkg-config.See the pkg-config man page for more details.解决方案:root@ubuntu:/home/lancer/tr069/easycwmp-1.5.2# PKG_CONFIG_PATH=/home/lancer/tr069/usr//lib/pkgconfig:$PKG_CONFIG_PATHroot@ubuntu:/home/lancer/tr069/easycwmp-1.5.2# export PKG_CONFIG_PATHroot@ubuntu:/home/lancer/tr069/easycwmp-1.5.2# echo $PKG_CONFIG_PATH/home/lancer/tr069/usr//lib/pkgconfig:root@ubuntu:/home/lancer/tr069/easycwmp-1.5.2# ./configure --prefix=/home/lancer/tr069/usr --host=mipsel-linux --enable-debug --enable-devel --enable-acs=multi --enable-jsonc=1OK或者vim /opt/buildroot-gcc463/usr/bin/pkg-config修改#!/bin/sh#PKG_CONFIG_LIBDIR=${PKG_CONFIG_LIBDIR:-/opt/buildroot-gcc463/usr/mipsel-buildroot-linux-uclibc/sysroot/usr/lib/pkgconfig:/opt/buildroot-gcc463/usr/mipsel-buildroot-linux-uclibc/sysroot/usr/share/pkgconfig} PKG_CONFIG_SYSROOT_DIR=${PKG_CONFIG_SYSROOT_DIR:-/opt/buildroot-gcc463/usr/mipsel-buildroot-linux-uclibc/sysroot} $(dirname $0)/pkgconf $@PKG_CONFIG_LIBDIR=${PKG_CONFIG_LIBDIR:-/home/lancer/tr069/usr/lib/pkgconfig:/home/lancer/tr069/usr/share/pkgconfig} PKG_CONFIG_SYSROOT_DIR=${PKG_CONFIG_SYSROOT_DIR:-} $(dirname $0)/pkgconf $@为PKG_CONFIG_LIBDIR=${PKG_CONFIG_LIBDIR:-/home/lancer/tr069/usr/lib/pkgconfig:/home/lancer/tr069/usr/share/pkgconfig} PKG_CONFIG_SYSROOT_DIR=${PKG_CONFIG_SYSROOT_DIR:-/opt/buildroot-gcc463/usr/mipsel-buildroot-linux-uclibc/sysroot} $(dirname $0)/pkgconf $@当然第二种更好,不然编译还会有如下问题。Build:
makeroot@ubuntu:/home/lancer/tr069/easycwmp-1.5.2# makeMaking all in binmake[1]: Entering directory `/home/lancer/tr069/easycwmp-1.5.2/bin'mipsel-linux-gcc -DPACKAGE_NAME=\"easycwmpd\" -DPACKAGE_TARNAME=\"easycwmpd\" -DPACKAGE_VERSION=\"1.5.2\" -DPACKAGE_STRING=\"easycwmpd\ 1.5.2\" -DPACKAGE_BUGREPORT=\"mohamed.kallel@pivasoftware.com\" -DPACKAGE_URL=\"\" -DPACKAGE=\"easycwmpd\" -DVERSION=\"1.5.2\" -DPACKAGE=\"easycwmpd\" -DVERSION=\"1.5.2\" -DJSONC=1 -DDEBUG=1 -DDEVEL=1 -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -I. -I/opt/buildroot-gcc463/usr/mipsel-buildroot-linux-uclibc/sysroot/home/lancer/tr069/usr/include -D_THREAD_SAFE -D_REENTRANT -I/opt/buildroot-gcc463/usr/mipsel-buildroot-linux-uclibc/sysroot/home/lancer/tr069/usr/include -g -O2 -MT ../src/easycwmpd-backup.o -MD -MP -MF ../src/.deps/easycwmpd-backup.Tpo -c -o ../src/easycwmpd-backup.o `test -f '../src/backup.c' || echo './'`../src/backup.cIn file included from ../src/backup.c:13:0:../src/backup.h:15:22: fatal error: microxml.h: No such file or directorycompilation terminated.make[1]: *** [../src/easycwmpd-backup.o] Error 1make[1]: Leaving directory `/home/lancer/tr069/easycwmp-1.5.2/bin'make: *** [all-recursive] Error 1看前边。自此,tr069相关库及程序都已交叉编译完毕。