编译ushare的时候出现‘struct sockaddr_storage’ has no member named ‘s_addr’
这是使用libupnp1.6.19出现版本号不兼容的错误。
解决方法:libupnp换成1.4.2版本号
配置:
----------------------------------------------------------------------------------------------------
$ ./configure
Checking forcompiler available...
Checking for locales...
Checking for ifaddrs...
Checking forlanginfo ...
Checking for iconv...
Checking for libixml...
Checking forlibthreadutil ...
Checkingfor libupnp >= 1.4.2 ...
uShare: configure isOK
version 1.1a
using libupnp 1.6.19
configuration:
install prefix /usr/local
configuration dir ${PREFIX}/etc
locales dir ${PREFIX}/share/locale
NLS support yes
DLNA support no
C compiler gcc
STRIP strip
make make
CPU x86 ()
debug symbols no
strip symbols yes
optimize yes
CFLAGS -I.. -W -Wall -D_LARGEFILE_SOURCE-D_FILE_OFFSET_BITS=64 -D_REENTRANT -D_GNU_SOURCE -O3 -DHAVE_LOCALE_H-DHAVE_SETLOCALE -DHAVE_IFADDRS_H -DHAVE_LANGINFO_H -DHAVE_LANGINFO_CODESET-DHAVE_ICONV
-pthread -I/usr/local/include/upnp
LDFLAGS
extralibs -lixml -lthreadutil -lpthread -lupnp-pthread -L/usr/local/lib
Creating config.mak...
Creating config.h...
-------------------------------------------------------------------------------------------------
须要开启DLNA支持的话,使用:
$./configure --enablle-dlna
编译:
$make
----------------------------------------------------------------------------
…
ushare.c: Infunction ‘handle_action_request’:
ushare.c:191:29:error: ‘struct sockaddr_storage’ has no member named ‘s_addr’
make[1]: ***[ushare.o] Error 1
make[1]: Leavingdirectory `/home/won/Downloads/ushare-1.1a/src'
make: *** [all]Error 2
---------------------------------------------------------------------------
查看ushare.c文件相应内容:
…/src/ushare.c
-----------------------------------------------------------------------------------------------------------------------
191
ip = request->CtrlPtIPAddr.s_addr;
192 ip = ntohl (ip);
193 sprintf (val, "%d.%d.%d.%d",
194 (ip >> 24) & 0xFF, (ip>> 16) & 0xFF, (ip >> 8) & 0xFF, ip & 0xFF);
-----------------------------------------------------------------------------------------------------------------------
看看struct sockaddr_storage的定义在哪个头文件
-------------------------------------------------------------------------
$ grep -rn"struct sockaddr_storage" /usr/local/include/
/usr/local/include/upnp/upnp.h:632: struct sockaddr_storage CtrlPtIPAddr;
/usr/local/include/upnp/upnp.h:679: struct sockaddr_storage CtrlPtIPAddr;
/usr/local/include/upnp/upnp.h:759: struct sockaddr_storage DestAddr;
-------------------------------------------------------------------------
这里看到的都不是它的定义
找了非常久还是没有发现它的定义,FQgoogle一下:
还有这个:
还是乖乖把libupnp换成1.4.2版本号吧。。。