Monday 25 August 2014

How to compile iperf3 for Windows

I was able to compile the binary for iperf3.0.6 code-base. The procedure is almost same as described in above blog with few changes.

1) Install Cygwin on windows : Download from

2) Run setup-x86.exe -> On the page of package selection screen click on 'Devel' so that 'Default' changes to 'Install' . We need development tools for compiling the code.

3) Download iper3.0.6 from

4) Copy it in c:\cygwin directory , unzip the iperf folder and copy the main directory to this (c:\cygwin folder)

5) Open the cygwin shell prompt, go to c:\cygwin\iperf-3-0.6 directory

6) ./configure  -> it should work fine

6) make
Making all in src
make[1]: Entering directory '/cygdrive/c/cygwin/iperf-3.0.6/iperf-3.0.6/src'
make  all-am
make[2]: Entering directory '/cygdrive/c/cygwin/iperf-3.0.6/iperf-3.0.6/src'
/bin/sh ../libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I.     -g -O2 -Wall -MT cjson.lo -MD -MP -MF .deps/cjson.Tpo -c -o cjson.lo cjson.c
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -g -O2 -Wall -MT cjson.lo -MD -MP -MF .deps/cjson.Tpo -c cjson.c  -DDLL_EXPORT -DPIC -o .libs/cjson.o
cjson.c: In function 'cJSON_strcasecmp':
cjson.c:58:2: warning: array subscript has type 'char' [-Wchar-subscripts]
  for ( ; tolower(*s1) == tolower(*s2); ++s1, ++s2)
cjson.c:58:2: warning: array subscript has type 'char' [-Wchar-subscripts]
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -g -O2 -Wall -MT cjson.lo -MD -MP -MF .deps/cjson.Tpo -c cjson.c -o cjson.o >/dev/null 2>&1
mv -f .deps/cjson.Tpo .deps/cjson.Plo
/bin/sh ../libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I.     -g -O2 -Wall -MT iperf_api.lo -MD -MP -MF .deps/iperf_api.Tpo -c -o iperf_api.lo iperf_api.c
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -g -O2 -Wall -MT iperf_api.lo -MD -MP -MF .deps/iperf_api.Tpo -c iperf_api.c  -DDLL_EXPORT -DPIC -o .libs/iperf_api.o
In file included from iperf_api.c:40:0:
iperf_api.h:227:5: error: conflicting types for 'iprintf'
 int iprintf(struct iperf_test *test, const char *format, ...) __attribute__ ((format(printf,2,3)));
In file included from /usr/include/stdio.h:29:0,
                 from iperf_api.c:13:
/usr/include/stdio.h:259:5: note: previous declaration of 'iprintf' was here
 int _EXFUN(iprintf, (const char *, ...)
iperf_api.c:2583:1: error: conflicting types for 'iprintf'
 iprintf(struct iperf_test *test, const char* format, ...)
In file included from /usr/include/stdio.h:29:0,
                 from iperf_api.c:13:
/usr/include/stdio.h:259:5: note: previous declaration of 'iprintf' was here
 int _EXFUN(iprintf, (const char *, ...)
Makefile:838: recipe for target 'iperf_api.lo' failed
make[2]: *** [iperf_api.lo] Error 1
make[2]: Leaving directory '/cygdrive/c/cygwin/iperf-3.0.6/iperf-3.0.6/src'
Makefile:615: recipe for target 'all' failed
make[1]: *** [all] Error 2
make[1]: Leaving directory '/cygdrive/c/cygwin/iperf-3.0.6/iperf-3.0.6/src'
Makefile:369: recipe for target 'all-recursive' failed
make: *** [all-recursive] Error 1


Got above error , looks like iprintf is defined at two places at /usr/include/stdio.h
and at iperf_api.c

Resolution :
search for declaration of iprintf in iperf_api.c files and replace it with another function name iiprintf. I have used Editplus for editing the files. Now search for the the same function iprintf in all files and replace it with iiprintf almost 3 files and 55 places need to be changed.

or use below command (not tested but got from above ref link)

cd ./src
find ./ -iname "*.[ch]" |xargs -n1 sed -i s'#iprintf#newprintf#g'

7) Again run make , it should pass this time

8) make install

9) copy /usr/local/bin/iperf3.exe -> to another folder where all files will be kept , lets name it as  "iperf306"

10) Now copy below files from C:\cygwin\bin into iperf306
  • cygwin1.dll
  • cyggcc_s-1.dll
  • cygstdc++-6.dll
11) copy the whole folder iperf306 to another pc and try running it

12) if while starting server or client you get below error , means ipv6 is not supported on the Windows machine.

 iperf3: error - unable to start listener for connections: Protocol not available

Try running with -4 option

iperf3.exe -4 -s

iperf3,exe -4 -c

13)  Now server is starting fine but below error came:

iperf3: error - unable to create a new stream: No such file or directory

Still trying to understand the issue , meanwhile if anyone can help , will be just GREAT  !

Will update if found solution.

Happy trying !

Updated : Sept 15, 2015

As per suggestions from Daniel in comments I did below changes and compiled the code again. Now it is working fine.


char template[] = "/tmp/iperf3.XXXXXX";


char template[] = "./iperf3.XXXXXX";

Thanks Daniel and Rion for your comments.