環境:mingw gcc 4.5.2
exosip2-3.6.0
osip2的編譯過程就不說了,下面直接進正題,解決以下錯誤:
eXtl_udp.c:181:3: error: 'retval' undeclared (first use in this function)
eXtl_udp.c:181:3: note: each undeclared identifier is reported only once
for each function it appears in
In file included from
/opt/mxe/usr/lib/gcc/i686-pc-mingw32/4.7.0/../../../../i686-pc-mingw32/include/fcntl.h:20:0,
from eXtl_tcp.c:29:
/opt/mxe/usr/lib/gcc/i686-pc-mingw32/4.7.0/../../../../i686-pc-mingw32/include/io.h:443:37:
error: conflicting types for 'closesocket'
In file included from eXosip2.h:43:0,
from eXtl_tcp.c:25:
/opt/mxe/usr/lib/gcc/i686-pc-mingw32/4.7.0/../../../../i686-pc-mingw32/include/winsock2.h:538:32:
note: previous declaration of 'closesocket' was here
eXtl_tcp.c:33:21: fatal error: Mstcpip.h: No such file or directory
compilation terminated.
好了,遇到這些問題,大家應該和我剛開始遇到一樣,有點發暈了吧,直接上patch
retval未定義,這個簡單吧:
eXtl_udp.c
--- ../../src/libeXosip2-3.6.0/src//eXtl_udp.c 2011-10-04 09:56:59 +0200
+++ .patches/libeXosip2-3.6.0/src//eXtl_udp.c 2012-07-11 17:07:16 +0200
@@ -178,7 +178,7 @@
res = setsockopt(udp_socket, IPPROTO_IPV6, IPV6_TCLASS,
(SOCKET_OPTION_VALUE)&tos, sizeof(tos));
#else
- retval = setsockopt(udp_socket, IPPROTO_IPV6, IP_TOS,
+ res = setsockopt(udp_socket, IPPROTO_IPV6, IP_TOS,
(SOCKET_OPTION_VALUE)&tos, sizeof(tos));
#endif
}
第二個定義衝突的問題:
eXtl_tcp.c
--- ../../src/libeXosip2-3.6.0/src//eXtl_tcp.c 2011-10-05 18:43:21 +0200
+++ .patches/libeXosip2-3.6.0/src//eXtl_tcp.c 2012-07-11 18:44:11 +0200
@@ -22,15 +22,25 @@
#include <mpatrol.h>
#endif
-#include "eXosip2.h"
-#include "eXtransport.h"
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
+#include "eXosip2.h"
+#include "eXtransport.h"
+
#ifdef WIN32
-#include <Mstcpip.h>
+/* MinGW Fix: Replacement for Mstcpip.h */
+
+struct tcp_keepalive {
+ ULONG onoff;
+ ULONG keepalivetime;
+ ULONG keepaliveinterval;
+};
+
+#define SIO_KEEPALIVE_VALS _WSAIOW(IOC_VENDOR,4)
+
#endif
eXtl_tls.c
--- ../../src/libeXosip2-3.6.0/src//eXtl_tls.c 2011-10-05 16:36:48 +0200
+++ .patches/libeXosip2-3.6.0/src//eXtl_tls.c 2012-07-11 18:14:37 +0200
@@ -22,8 +22,6 @@
#include <mpatrol.h>
#endif
-#include "eXosip2.h"
-#include "eXtransport.h"
#include <sys/stat.h>
@@ -31,8 +29,11 @@
#include <fcntl.h>
#endif
+#include "eXosip2.h"
+#include "eXtransport.h"
+
#ifdef WIN32
-#include <Mstcpip.h>
+/* MinGW Fix: Replacement for Mstcpip.h */
+
+struct tcp_keepalive {
+ ULONG onoff;
+ ULONG keepalivetime;
+ ULONG keepaliveinterval;
+};
+
+#define SIO_KEEPALIVE_VALS _WSAIOW(IOC_VENDOR,4)
#include <wincrypt.h> #endif
編譯 exosip2-3.6.0
#export LIBS='-lws2_32-lwsock32 -liphlpapi -ldnsapi -lssl32 -lcrypto -lpthread'
# ./configure --enable-openssl --enable-pthread --prefix=/usr/local/exosip2/
#make
#make install