EASYCWMP Cross-compiling

Source: Internet
Author: User



Original works, reproduced please indicate the source



Copyright:weishusheng 2015.3.18



Email:[email protected]



tel:13657214139






Platform:



Linux version 2.6.32-279.el6.x86_64



Cross compiler path:/opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-



Development Board: FL2440



Board Runtime kernel: linux3.0



Development Board File system: JFFS2






First, the preparatory work



1. Create the FL-EASYCWMP directory to store the installation files



[Email protected] ~]$ mkdir FL-EASYCWMP






2. Create the Install directory



[Email protected] ~]$ CD fl-easycwmp/
[[email protected] fl-easycwmp]$ ls
[[email protected] fl-easycwmp]$ mkdir Install
[[email protected] fl-easycwmp]$ ls
Install



Second, cross-compiling json-c



1. Get json-c source files



[[email protected] fl-easycwmp]$ git clone git://github.com/json-c/json-c.git./json-c






2. Create build.sh



[Email protected] json-c]$ vim build.sh



#!/bin/bash
Prj_path= ' pwd '
#CROSS =/opt/buildroot-2011.11/arm920t/usr/bin/arm-linux-
cross=/opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-
Make clean
#autoreconf-I.
Export CC=${CROSS}GCC
Export Cpp=${cross}cpp
Export As=${cross}as
Export LD=${CROSS}LD
Export Ar=${cross}ar
Export Ranlib=${cross}ranlib
Export Strip=${cross}strip
Export Ac_cv_func_malloc_0_nonnull=yes
Export Ac_cv_func_realloc_0_nonnull=yes
Export Ac_cv_have_decl_isinf=yes
Export Ac_cv_have_decl_isnan=yes
#export Ldflags + =-lm
./configure--enable-rdrand--disable-dependency-tracking--with-package--with-gnu-ld--with-pic--bu
Ild=i686-pc-linux-gnu--host=arm-linux--prefix=${prj_path}/. /install



By the way, Cflags's-wall-o2-g in makefile.



-wall is open warning switch,-O stands for default optimizations, optional:-O 0 is not optimized,-o1 low-level optimizations,-O2 intermediate optimizations,-O3 advanced optimizations,-os code space optimization.
-G is the generation of debug information, and the resulting executable file has the debug information associated with the source code






3. Installing Json-c



[Email protected] json-c]$ sh build.sh



Then change the Ldflags =-LM in the generated makefile, and note that after each modification, make clean is simply to clear the previously compiled executable and configuration files. And make Distclean to clear all the generated files. )



Make



Make install






Third, installation Libubox



1. Get Libubox



[[email protected] fl-easycwmp]$ git clone git://nbd.name/luci2/libubox.git./libubox



2. In the project Master CMakeLists.txt first add the following statement: (# #注意Linux第一个字母为大写, otherwise cmake do not know)



[Email protected] libubox]$ vim CMakeLists.txt



SET (Cmake_system_name Linux)
SET (Toolchain_dir "/OPT/BUILDROOT-2012.08/ARM920T/USR")
SET (Cmake_find_root_path ${toolchain_dir})
SET (Cmake_find_root_path_mode_program BOTH)
SET (cmake_find_root_path_mode_library "/home/weishusheng/fl-easycwmp/install/lib/")
SET (Cmake_find_root_path_mode_include only)
SET (Cmake_c_compiler ${TOOLCHAIN_DIR}/BIN/ARM-LINUX-GCC)
SET (Cmake_cxx_compiler ${toolchain_dir}/bin/arm-linux-g++)
SET (Cmake_install_prefix "/home/weishusheng/fl-easycwmp/install/")






3. Generate makefile



[Email protected] libubox]$ CMake Cmakelists.txt-dbuild_lua=off






4.make



Error Resolution:



Error 1



/home/weishusheng/fl-easycwmp/libubox/blobmsg_json.c:in function ' __blobmsg_add_json ':
/home/weishusheng/fl-easycwmp/libubox/blobmsg_json.c:78:2: error:implicit declaration of function ' Is_error '



Analysis: Is_error not defined, also encountered this problem when compiling on the PC, we know that his definition is # define IS_ERROR (PTR) (ptr = = NULL), then add the definition



[Email protected] libubox]$ VIM/HOME/WEISHUSHENG/FL-EASYCWMP/LIBUBOX/BLOBMSG_JSON.C



#include "Blobmsg.h"
#include "Blobmsg_json.h"
#define IS_ERROR (PTR) (ptr = = NULL)






Error 2



Cannot find-ljson-c



Specify JSON-C library path in CMakeLists.txt



[Email protected] libubox]$ vim CMakeLists.txt



Link_directories (/home/weishusheng/fl-easycwmp/install/lib/)






Error 3



/home/weishusheng/fl-easycwmp/libubox/jshn.c:in function ' Jshn_parse ':
/home/weishusheng/fl-easycwmp/libubox/jshn.c:162:2: error:implicit declaration of function ' Is_error '



Add definition



#define IS_ERROR (PTR) (ptr = = NULL)






4.



/home/weishusheng/cross_easycwmp/install/lib/libjson-c.so:undefined reference to ' __isnan '
/home/weishusheng/cross_easycwmp/install/lib/libjson-c.so:undefined reference to ' __isinf '



This problem makes me crazy, but you do not follow my blog do not appear this problem, because I wrote Json-c in front of the installation to solve for you, if you encounter a similar problem, you can try to compile json-c when adding



Export Ac_cv_have_decl_isinf=yes
Export Ac_cv_have_decl_isnan=yes



and connect to the math library that LDFLAGS+=-LM






Fourth. installation of UCI



1. Get UCI



[[email protected] fl-easycwmp]$ git clone git://nbd.name/uci.git./uci






2. Modify CMakeList.txt



[Email protected] uci]$ vim CMakeLists.txt
SET (Cmake_system_name Linux)
SET (Toolchain_dir "/OPT/BUILDROOT-2012.08/ARM920T/USR")
SET (Cmake_find_root_path ${toolchain_dir})
SET (Cmake_find_root_path_mode_program BOTH)
SET (Cmake_find_root_path_mode_library only)
SET (Cmake_find_root_path_mode_include only)
SET (Cmake_c_compiler ${TOOLCHAIN_DIR}/BIN/ARM-LINUX-GCC)
SET (Cmake_cxx_compiler ${toolchain_dir}/bin/arm-linux-g++)
SET (Cmake_install_prefix "/home/weishusheng/fl-easycwmp/install/")

Cmake_minimum_required (VERSION 2.6)






3. Generate makefile



[Email protected] uci]$ CMake Cmakelists.txt-dbuild_lua=off






4.make



/opt/buildroot-2012.08/arm920t/usr/lib/gcc/arm-unknown-linux-uclibcgnueabi/4.5.4/. /.. /.. /.. /arm-unknown-linux-uclibcgnueabi/bin/ld:cannot Find-lubox



Join Link_directories (/home/weishusheng/fl-easycwmp/install/lib/) in CMakeList.txt, problem solving






5.make Install






Fifth. Installation of Ubus



1. Get Ubus



git clone git://nbd.name/luci2/ubus.git./ubus






2. Modify CMakeList.txt



[Email protected] ubus]$ vim CMakeLists.txt
SET (Cmake_system_name Linux)
SET (Toolchain_dir "/OPT/BUILDROOT-2012.08/ARM920T/USR")
SET (Cmake_find_root_path ${toolchain_dir})
SET (Cmake_find_root_path_mode_program BOTH)
SET (Cmake_find_root_path_mode_library only)
SET (Cmake_find_root_path_mode_include only)
SET (Cmake_c_compiler ${TOOLCHAIN_DIR}/BIN/ARM-LINUX-GCC)
SET (Cmake_cxx_compiler ${toolchain_dir}/bin/arm-linux-g++)
SET (Cmake_install_prefix "/home/weishusheng/fl-easycwmp/install/")






3. Generate makefile



[Email protected] ubus]$ CMake Cmakelists.txt-dbuild_lua=off






CMake error:the Following variables is used in this project, but they is set to NOTFOUND.
Please set them or make sure they is set and tested correctly in the CMake files:
Json
Linked by target "CLI" in Directory/home/weishusheng/fl-easycwmp/ubus






Workaround: Specify the JSON library path in CMakeList.txt by modifying set (Cmake_find_root_path_mode_library only) to



SET (cmake_find_root_path_mode_library "/home/weishusheng/fl-easycwmp/install/lib") can be resolved.






4.make



Error: Cannot Find-lubox



Workaround: Add link_directories (/home/weishusheng/fl-easycwmp/install/lib) in cmakelists






Error: Json/json.h:no such file or directory



Workaround: Cross compile the default standard header file is under the cross compiler path, you can use echo ' main () {} ' |/opt/buildroot-



2012.08/ARM920T/USR/BIN/ARM-LINUX-GCC-E-V-command to view, we add the need to use the header file to the appeal command found location can be
, in addition, cross-compilation will go to the system default standard library directory to find the library file, which will cause the format is not met, we need to use the-L and-l to specify the library file



[Email protected] json-c]$ pwd
/home/weishusheng/fl-easycwmp/install/include/json-c
[email protected] json-c]$ sudo mkdir/opt/buildroot-2012.08/arm920t/usr/arm-unknown-linux-
Uclibcgnueabi/sysroot/usr/include/json
[[email protected] json-c]$ sudo cp */opt/buildroot-2012.08/arm920t/usr/arm-unknown-linux-
Uclibcgnueabi/sysroot/usr/include/json
[Email protected] json-c]$






Sixth. installation of Microxml



1. Get the source file



[[email protected] fl-easycwmp]$ git clone git://dev.freecwmp.org/microxml./microxml






2. Establish build.sh file



[Email protected] microxml]$ vim build.sh
#!/bin/bash
Prj_path= ' pwd '
#CROSS =/opt/buildroot-2011.11/arm920t/usr/bin/arm-linux-
cross=/opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-
Make Distclean
Autoreconf-i
Export CC=${CROSS}GCC
Export Cpp=${cross}cpp
Export As=${cross}as
Export LD=${CROSS}LD
Export Ar=${cross}ar
Export Ranlib=${cross}ranlib
Export Strip=${cross}strip
./configure--host=arm-linux--prefix=${prj_path}/.. /install
Make && make install






3. Implementation



[Email protected] microxml]$ sh build.sh






//Seventh, put shflags.sh in the/usr/share/shflags/directory






Seventh, finally to compile the EASYCWMP



1. Get the source file



[Email protected] fl-easycwmp]$ wget http://easycwmp.org/download/easycwmp-1.0.5.tar.gz






2. Unzip, rename easycwmp-1.0.5 to EASYCWMP and enter the directory



[email protected] fl-easycwmp]$ CP. /cross_easycwmp/easycwmp-1.0.5.tar.gz.



[Email protected] fl-easycwmp]$ MV easycwmp-1.0.5 EASYCWMP
[Email protected] fl-easycwmp]$ CD EASYCWMP






3. Generate makefile



[Email protected] easycwmp]$ autoreconf-i






3. Generate makefile



[Email protected] easycwmp]$ CC=/OPT/BUILDROOT-2012.08/ARM920T/USR/BIN/ARM-LINUX-GCC ar=/opt/buildroot-2012.08/ Arm920t/usr/bin/arm-linux-ar Ld=/opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-ld AS=/opt/buildroot-2012.08/ Arm920t/usr/bin/arm-linux-as Ranlib=/opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-ranlib CPP=/opt/ Buildroot-2012.08/arm920t/usr/bin/arm-linux-cpp./configure--host=arm-linux--prefix=/home/weishusheng/ Fl-easycwmp/install microxml_cflags= "-i/home/weishusheng/fl-easycwmp/install/include-d_thread_safe-d_reentrant" microxml_libs= "-l/home/weishusheng/fl-easycwmp/install/lib-lmicroxml-lpthread"--enable-debug--enable-devel-- Enable-acs=multi--enable-jsonc=1--with-uci-include-path=/home/weishusheng/fl-easycwmp/uci/






4.[[email protected] easycwmp]$ make






Error: Curl/curl.h:no such file or directory



Workaround: A, cross-compile Curl (http://curl.haxx.se/download.html) First,



b,[[email protected] include]$ sudo mkdir/opt/buildroot-2012.08/arm920t/usr/arm-unknown-linux-



Uclibcgnueabi/sysroot/usr/include/curl



c, [[email protected] fl-easycwmp]$ TAR-XZF curl-7.41.0.tar.gz



D, Vim build.sh


#!/bin/bash
Prj_path= ' pwd '
#CROSS =/opt/buildroot-2011.11/arm920t/usr/bin/arm-linux-
cross=/opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-
Make Distclean
Autoreconf-i
Export CC=${CROSS}GCC
Export Cpp=${cross}cpp
Export As=${cross}as
Export LD=${CROSS}LD
Export Ar=${cross}ar
Export Ranlib=${cross}ranlib
Export Strip=${cross}strip
./configure--host=arm-linux--prefix=${prj_path}/.. /install
Make && make install


E. Copy the head file to the appropriate location



[Email protected] curl]$ pwd
/home/weishusheng/fl-easycwmp/install/include/curl
[[email protected] curl]$ ls
Curlbuild.h curlrules.h easy.h multi.h typecheck-gcc.h
Curl.h curlver.h mprintf.h Stdcheaders.h



[[email protected] curl]$ sudo cp */opt/buildroot-2012.08/arm920t/usr/arm-unknown-linux-uclibcgnueabi/sysroot/usr/ Include/curl






Error: Src/ubus.c:14:21:fatal error:libubus.h:no such file or directory
Workaround:



[Email protected] ubus]$ pwd
/home/weishusheng/fl-easycwmp/ubus
[email protected] ubus]$ sudo cp libubus.h/opt/buildroot-2012.08/arm920t/usr/arm-unknown-linux-
uclibcgnueabi/sysroot/usr/include/






Error: Ubusmsg.h:no such file or directory
Workaround:



[Email protected] ubus]$ pwd
/home/weishusheng/cross_easycwmp/ubus



[email protected] ubus]$ sudo cp ubusmsg.h/opt/buildroot-2012.08/arm920t/usr/arm-unknown-linux-
uclibcgnueabi/sysroot/usr/include/






Error: Ubus_common.h:no such file or directory



Workaround:



[email protected] ubus]$ sudo cp ubus_common.h/opt/buildroot-2012.08/arm920t/usr/arm-unknown-linux-
uclibcgnueabi/sysroot/usr/include/






Error: src/json.c:42:undefined reference to ' Is_error '



Workaround:



Vim SRC/JSON.C



#define IS_ERROR (PTR) (ptr = = NULL)






[[email protected] easycwmp]$ make



[[email protected] easycwmp]$ make install






At this point easycwmp cross-compile, then put on the FL2440 Development Board to run, on the Development Board to do the relevant settings, please refer to the next blog post.






EASYCWMP Cross-compiling


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.