easycwmp的編譯

 

原創做品,轉載請註明出處,嚴禁非法轉載。json

 

copyright:weishusheng   2015.3.18  ide

 

email:642613208@qq.comui

 

 

 

注:此處的編譯指的是直接用系統自帶的gcc編譯器進行編譯,而不是交叉編譯。編譯好後是直接放在CentOS上運行的。spa

easycwmp屬於第三方程序,我在編譯時遇到了幾個問題,困擾本身好久,也怪本身沒靜下心分析,今天終於解決了,在此作個總結。命令行

一.具體安裝過程請看README安裝說明文檔debug

二.第一個問題xml

checking for MICROXML... configure: error: Package requirements (microxml) were not met:ip

No package 'microxml' foundrem

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.文檔

Alternatively, you may set the environment variables MICROXML_CFLAGS
and MICROXML_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

microxml是以前按照easycwmp的README裝的,沒問題,能夠排除。

pkg-config的做用是檢查程序賴以安裝的各個庫及文件是否安裝,說明各個庫的路徑的腳本以.pc結尾,因而找到與microxml同一目錄下的microxml.pc文件,裏面果真定義了

1 prefix=/usr
2 exec_prefix=/usr
3 libdir=${exec_prefix}/lib
4 includedir=${prefix}/include
5
6 Name: microxml
7 Description: micro XML library
8 Version: 1.0
9 Libs: -L${exec_prefix}/lib -lmicroxml -lpthread
10 Cflags: -I${prefix}/include -D_THREAD_SAFE -D_REENTRANT

只是用./configure --enable-debug --enable-devel --enable-acs=multi --enable-jsonc=1編譯時系統找不到而已

因而在命令行給出路徑

./configure MICROXML_CFLAGS="-I/usr/include/ -D_THREAD_SAFE -D_REENTRANT" MICROXML_LIBS="-L/usr/lib -lmicroxml -lpthread" --enable-debug --enable-devel --enable-acs=multi --enable-jsonc=1

Package requirements (microxml) were not met的問題解決。

三./home/weishusheng/cwmp_client/easycwmp1.0.1/bin/../src/json.c:168: undefined reference to `is_error'

因而找到is_error的定義,在json-c/bits.h:有這樣的定義#define is_error(ptr) (ptr == NULL)

因而在json.c里加#define is_error(ptr) (ptr == NULL)進去

問題解決。

四.../src/config.c:125: error: storage size of ‘tm’ isn’t known

用ctags找到struct tm 的定義,在time.h裏
在src/config.c 添加#include <time.h>便可,或者能夠看到/usr/include/time.h裏定義了struct tm以下:

 

struct tm
{
int tm_sec; /* Seconds. [0-60] (1 leap second) */
int tm_min; /* Minutes. [0-59] */
int tm_hour; /* Hours. [0-23] */
int tm_mday; /* Day. [1-31] */
int tm_mon; /* Month. [0-11] */
int tm_year; /* Year - 1900. */
int tm_wday; /* Day of week. [0-6] */
int tm_yday; /* Days in year.[0-365] */
int tm_isdst; /* DST. [-1/0/1]*/

 

#ifdef __USE_BSD
long int tm_gmtoff; /* Seconds east of UTC. */
__const char *tm_zone; /* Timezone abbreviation. */
#else
long int __tm_gmtoff; /* Seconds east of UTC. */
__const char *__tm_zone; /* Timezone abbreviation. */
#endif
};

 

也可直接把tm 的定義嵌入src/config.c

相關文章
相關標籤/搜索