2013-10-03 151 views
0

我正试图在Windows上使用minGW/MSYS编译iPerf。当我运行./configure一切看起来都正常:使用minGW在Windows上编译iPerf2.0.5

$ ./configure 
checking for a BSD-compatible install... /bin/install -c 
checking whether build environment is sane... yes 
checking for gawk... gawk 
checking whether make sets $(MAKE)... yes 
checking for g++... g++ 
checking whether the C++ compiler works... yes 
checking for C++ compiler default output file name... a.exe 
checking for suffix of executables... .exe 
checking whether we are cross compiling... no 
checking for suffix of object files... o 
checking whether we are using the GNU C++ compiler... yes 
checking whether g++ accepts -g... yes 
checking for style of include used by make... GNU 
checking dependency style of g++... gcc3 
checking for gcc... gcc 
checking whether we are using the GNU C compiler... yes 
checking whether gcc accepts -g... yes 
checking for gcc option to accept ISO C89... none needed 
checking dependency style of gcc... gcc3 
checking for library containing strerror... none required 
checking whether make sets $(MAKE)... (cached) yes 
checking for ranlib... ranlib 
checking build system type... i686-pc-mingw32 
checking host system type... i686-pc-mingw32 
checking for the pthreads library -lpthreads... no 
checking whether pthreads work without any flags... no 
checking whether pthreads work with -Kthread... no 
checking whether pthreads work with -kthread... no 
checking for the pthreads library -llthread... no 
checking whether pthreads work with -pthread... no 
checking whether pthreads work with -pthreads... no 
checking whether pthreads work with -mthreads... no 
checking for the pthreads library -lpthread... no 
checking whether pthreads work with --thread-safe... no 
checking whether pthreads work with -mt... no 
checking for pthread-config... no 
checking for gethostbyname... no 
checking for gethostbyname in -lnsl... no 
checking for socket... no 
checking for socket in -lsocket... no 
checking how to run the C preprocessor... gcc -E 
checking for grep that handles long lines and -e... /bin/grep 
checking for egrep... /bin/grep -E 
checking for ANSI C header files... yes 
checking for sys/types.h... yes 
checking for sys/stat.h... yes 
checking for stdlib.h... yes 
checking for string.h... yes 
checking for memory.h... yes 
checking for strings.h... yes 
checking for inttypes.h... yes 
checking for stdint.h... yes 
checking for unistd.h... yes 
checking arpa/inet.h usability... no 
checking arpa/inet.h presence... no 
checking for arpa/inet.h... no 
checking libintl.h usability... no 
checking libintl.h presence... no 
checking for libintl.h... no 
checking netdb.h usability... no 
checking netdb.h presence... no 
checking for netdb.h... no 
checking netinet/in.h usability... no 
checking netinet/in.h presence... no 
checking for netinet/in.h... no 
checking for stdlib.h... (cached) yes 
checking for string.h... (cached) yes 
checking for strings.h... (cached) yes 
checking sys/socket.h usability... no 
checking sys/socket.h presence... no 
checking for sys/socket.h... no 
checking sys/time.h usability... yes 
checking sys/time.h presence... yes 
checking for sys/time.h... yes 
checking syslog.h usability... no 
checking syslog.h presence... no 
checking for syslog.h... no 
checking for unistd.h... (cached) yes 
checking for an ANSI C-conforming const... yes 
checking for size_t... yes 
checking for ssize_t... yes 
checking whether time.h and sys/time.h may both be included... yes 
checking whether struct tm is in sys/time.h or time.h... time.h 
checking for stdint types... stdint.h (shortcircuit) 
make use of stdint.h in include/iperf-int.h (assuming C99 compatible system) 
checking 3rd argument of accept... 
checking for pid_t... yes 
checking vfork.h usability... no 
checking vfork.h presence... no 
checking for vfork.h... no 
checking for fork... no 
checking for vfork... no 
checking for stdlib.h... (cached) yes 
checking for GNU libc compatible malloc... yes 
checking for working memcmp... yes 
checking sys/select.h usability... no 
checking sys/select.h presence... no 
checking for sys/select.h... no 
checking for sys/socket.h... (cached) no 
checking types of arguments for select... int,int *,struct timeval * 
checking return type of signal handlers... void 
checking for strftime... yes 
checking for vprintf... yes 
checking for _doprnt... no 
checking for atexit... yes 
checking for gettimeofday... yes 
checking for memset... yes 
checking for pthread_cancel... no 
checking for select... no 
checking for strchr... yes 
checking for strerror... yes 
checking for strtol... yes 
checking for usleep... yes 
checking for snprintf... yes 
checking for inet_pton... no 
checking for inet_ntop... no 
checking for gettimeofday... (cached) yes 
checking *printf() support for %lld... yes 
checking size of bool... 0 
checking if true is defined... yes 
checking whether byte ordering is bigendian... no 
checking for struct ip_mreq... no 
checking whether IP_ADD_MEMBERSHIP is declared... no 
checking for multicast support... no 
checking for struct sockaddr_storage... no 
checking for struct sockaddr_in6... no 
checking whether AF_INET6 is declared... no 
checking for IPv6 headers and structures... no 
checking whether make is GNU make... yes 
configure: creating ./config.status 
config.status: creating Makefile 
config.status: creating compat/Makefile 
config.status: creating doc/Makefile 
config.status: creating include/Makefile 
config.status: creating src/Makefile 
config.status: creating man/Makefile 
config.status: creating config.h 
config.status: config.h is unchanged 
config.status: executing depfiles commands 
config.status: executing include/iperf-int.h commands 
config.status: creating include/iperf-int.h : _IPERF_INCLUDE_IPERF_INT_H 
config.status: include/iperf-int.h is unchanged 

当我试图让即使./configure一会儿,它声称它发现的功能我得到与gettimeofday的功能的错误的程序。

$ make 
make all-recursive 
make[1]: Entering directory `/c/users/c_bhaskv/desktop/iperf-2.0.5' 
Making all in compat 
make[2]: Entering directory `/c/users/c_bhaskv/desktop/iperf-2.0.5/compat' 
if g++ -DHAVE_CONFIG_H -I. -I. -I.. -I../include -I../include -Wall -O2 -MT delay.o -MD -MP -MF ".deps/delay.Tpo" -c -o delay.o delay.cpp; \ 
     then mv -f ".deps/delay.Tpo" ".deps/delay.Po"; else rm -f ".deps/delay.Tpo"; exit 1; fi 
In file included from ../include/Timestamp.hpp:63:0, 
       from delay.cpp:53: 
../include/headers.h:93:0: warning: "_WIN32_WINNT" redefined [enabled by default] 
    #define _WIN32_WINNT 0x0400 /* use (at least) WinNT 4.0 API */ 
^ 
In file included from c:\mingw\include\_mingw.h:35:0, 
       from c:\mingw\include\stdlib.h:27, 
       from ../include/headers.h:78, 
       from ../include/Timestamp.hpp:63, 
       from delay.cpp:53: 
c:\mingw\include\sdkddkver.h:154:0: note: this is the location of the previous definition 
# define _WIN32_WINNT _WIN32_WINNT_WIN2K 
^ 
In file included from delay.cpp:53:0: 
../include/Timestamp.hpp: In member function 'void Timestamp::setnow()': 
../include/Timestamp.hpp:93:36: error: 'gettimeofday' was not declared in this scope 
     gettimeofday(&mTime, NULL); 
            ^
delay.cpp: In function 'void delay_loop(long unsigned int)': 
delay.cpp:64:21: error: aggregate 'delay_loop(long unsigned int)::timespec requested' has incomplete type and cannot be defined 
    struct timespec requested, remaining; 
        ^
delay.cpp:64:32: error: aggregate 'delay_loop(long unsigned int)::timespec remaining' has incomplete type and cannot be defined 
    struct timespec requested, remaining; 
           ^
delay.cpp:69:44: error: 'nanosleep' was not declared in this scope 
    while (nanosleep(&requested, &remaining) == -1) 
              ^

有关如何解决这些错误的想法?

感谢

+0

源码位置:http://sourceforge.net/projects/iperf/ – Mpressiv

回答

0

注意:

checking sys/time.h usability... yes 
checking sys/time.h presence... yes 
checking for sys/time.h... yes 

然后,如果它说:

error: 'gettimeofday' was not declared in this scope 

那么很明显的东西是错误的库本身的标题,即sys/time.h根本就不是适当地包括。快速浏览<iperf-dir>/include/headers.h并快速浏览时发现,当我们在Windows上时,sys/time.h不包括在内,即在#ifdef WIN32块中,而对于Unix块(在#else中)确实包括它。其结果是,所有你需要做的是补充:

#include <sys/time.h> 

<iperf-dir>/include/headers.h例如上线#91。

虽然这会解决您当前的问题,但您在编译过程中稍后会遇到一些不可编译的代码(即,编写时有错误)并仍然失败。坦率地说,这个库在Windows可移植性方面设计得非常好。代码看起来相当古老和丑陋,所以它不会编译出来并不奇怪。 iperf 3可能会带来更多运气,因为它们可能会提高图书馆的质量和便携性问题。

相关问题