在windows libusbmuxd编译中使用mingw编译c

时间:2015-07-22 09:08:58

标签: c++ c windows mingw

所以我已经成功地在windows mingw上编译libusbmuxd以便将它用于Windows平台。

然而,虽然autogen.sh和configure完成没有错误

它无法在下面制作libusbmuxd。有没有人对此有任何想法?是否有关于如何在Windows中构建的明确说明?

$ make
make all-recursive
make[1]: Entering directory /home/Naver/libusbmuxd-1.0.10' Making all in common make[2]: Entering directory/home/Naver/libusbmuxd-1.0.10/common'
CC collection.lo
CCLD libinternalcommon.la
make[2]: Leaving directory /home/Naver/libusbmuxd-1.0.10/common' Making all in src make[2]: Entering directory/home/Naver/libusbmuxd-1.0.10/src'
CC libusbmuxd.lo
libusbmuxd.c:46:26: error: expected ';', ',' or ')' before numeric constant
#define sleep(x) Sleep(x*1000)
^
libusbmuxd.c:46:25: error: expected ';', ',' or ')' before '' token
#define sleep(x) Sleep(x*1000)
^
make[2]: ** [libusbmuxd.lo] Error 1
make[2]: Leaving directory /home/Naver/libusbmuxd-1.0.10/src' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory/home/Naver/libusbmuxd-1.0.10'
make: *** [all] Error 2

1 个答案:

答案 0 :(得分:0)

可能是(请参阅稍后*)您机器上的本地问题,因为查看the code该行是正常的。某些头文件可能已损坏/损坏。您可以检查上面直接包含的<winsock2.h>,并且可能对此位置的编译器错误负责:

#ifdef WIN32
#include <windows.h>
#include <winsock2.h>
#define sleep(x) Sleep(x*1000)

因此,您可以预处理源文件(cpp -E libusbmuxd.c >libusbmuxd_pp.c)并检查结果。 (尝试编译它以找到错误的新行号。)

*)顺便说一下,我在MinGW的cpp给了我这个:

D:\test>cpp -E test.c >test2.c
In file included from test.c:45:0:
d:\mingw\x86_64-w64-mingw32\include\winsock2.h:15:2: warning: #warning  Please include winsock2.h before windows.h [-Wcpp]
 #warning Please include winsock2.h before windows.h
  ^

因此,在源代码中交换#include指令可能已经解决了这个问题。