Компиляция iPerf2.0.5 в Windows с помощью minGW

Я пытаюсь скомпилировать iPerf в Windows, используя minGW/MSYS. Когда я запускаю ./configure, все выглядит нормально:

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

Когда я пытаюсь создать программу, я получаю сообщение об ошибке с функцией gettimeofday, хотя в ./configure утверждается, что она найдена.

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

любые идеи о том, что делать, чтобы исправить эти ошибки?

Спасибо


person Mpressiv    schedule 03.10.2013    source источник
comment
Расположение источника: sourceforge.net/projects/iperf   -  person Mpressiv    schedule 03.10.2013


Ответы (1)


Уведомление:

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 и быстрый просмотр показывают, что sys/time.h не включается, когда мы работаем в Windows, то есть в блоке #ifdef WIN32, тогда как для блока Unix (в #else) он действительно включен. В результате все, что вам нужно сделать, это добавить:

#include <sys/time.h>

на <iperf-dir>/include/headers.h, например, в строке №91.

Хотя это решит вашу текущую проблему, позже вы столкнетесь с некомпилируемым кодом (то есть написанным с ошибками) во время компиляции и все равно потерпите неудачу. Кроме того, откровенно говоря, библиотека ужасно спроектирована с точки зрения переносимости Windows. Код выглядит довольно древним и уродливым, поэтому неудивительно, что он не компилируется. Возможно, вам повезет больше с iperf 3, так как они могли улучшить качество библиотеки и ее проблемы переносимости.

person Alexander Shukaev    schedule 11.10.2013