easycwmp的编译

原创作品,转载请注明出处,严禁非法转载。

copyright:weishusheng   2015.3.18  

email:642613208@qq.com

 

注:此处的编译指的是直接用系统自带的gcc编译器进行编译,而不是交叉编译。编译好后是直接放在CentOS上运行的。

easycwmp属于第三方程序,我在编译时遇到了几个问题,困扰自己很久,也怪自己没静下心分析,今天终于解决了,在此做个总结。

一.具体安装过程请看README安装说明文档

二.第一个问题

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

No package 'microxml' found

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

原文地址:https://www.cnblogs.com/thinkinglife/p/4191346.html