简体   繁体   中英

Compiling iPerf2.0.5 on Windows with minGW

I am trying to compile iPerf on Windows using minGW/MSYS. When I run ./configure everything looks okay:

$ ./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

When I try to make the program I am getting an error with the gettimeofday function even though in ./configure it claims that it found the function.

$ 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)
                                            ^

any ideas on what to do to fix these errors?

Thanks

Notice:

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

Then if it says:

error: 'gettimeofday' was not declared in this scope

then obviously something is wrong in the headers of the library itself, ie sys/time.h is simply not included properly. Going to <iperf-dir>/include/headers.h and skimming through it quickly reveals that sys/time.h is not included when we are on Windows, ie in the #ifdef WIN32 block, while for Unix block (in #else ) it is indeed included. As a result, all you have to do is to add:

#include <sys/time.h>

to <iperf-dir>/include/headers.h for example on line #91.

Although this will solve your current problem, you will later hit some uncompilable code (ie written with mistakes) during compilation and still fail. Furthermore, frankly speaking, the library is terribly designed in terms of Windows portability. The code looks quite ancient and ugly, so it's no surprise that it does not compile. You might have more luck with iperf 3 as they might have improved the quality of the library and its portability issues.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM