我想用Linux的mingw32編譯this。Winsock2.h:沒有這樣的文件或目錄
不過,我得到以下錯誤和警告:
# i586-mingw32msvc-gcc ms04-020.c -lws2_32 -o ms04-020.exe
ms04-020.c:43:22: error: Winsock2.h: No such file or directory
ms04-020.c: In function ‘main’:
ms04-020.c:113: warning: incompatible implicit declaration of built-in function ‘printf’
ms04-020.c:114:11: warning: unknown escape sequence '\;'
ms04-020.c: In function ‘readwrite’:
ms04-020.c:251: warning: incompatible implicit declaration of built-in function ‘printf’
ms04-020.c:259: warning: incompatible implicit declaration of built-in function ‘printf’
ms04-020.c:264: warning: incompatible implicit declaration of built-in function ‘printf’
ms04-020.c:279: warning: incompatible implicit declaration of built-in function ‘printf’
ms04-020.c:285: warning: incompatible implicit declaration of built-in function ‘printf’
ms04-020.c:290: warning: incompatible implicit declaration of built-in function ‘printf’
ms04-020.c:301: warning: incompatible implicit declaration of built-in function ‘printf’
ms04-020.c:307: warning: incompatible implicit declaration of built-in function ‘printf’
ms04-020.c:312: warning: incompatible implicit declaration of built-in function ‘printf’
ms04-020.c: In function ‘client_connect’:
ms04-020.c:333: warning: incompatible implicit declaration of built-in function ‘printf’
ms04-020.c:343: warning: incompatible implicit declaration of built-in function ‘printf’
如何解決有關Winsock2.h
錯誤?我確實設法在Windows 7上使用Visual Studio 2013進行編譯,這將是一個可接受的解決方案,但compiling with Visual Studio 2010 or later makes the application incompatible with the Windows 2000 target OS。所以即使它以這種方式構建,二進制文件也不會執行。
是Windows系統乾的頭文件在編譯器默認搜索的路徑?您可能需要使用'-I'(大寫i)選項來添加路徑。 – 2014-10-11 18:16:22
@JoachimPileborg:我沒有'Winsock2.h'文件 - 我可以在哪裏得到它? – SilverlightFox 2014-10-11 18:18:43
我不知道是否有一個包含WIN32系統庫和頭文件的MinGW包,你應該找那個。如果沒有,應該有大量的教程如何做到這一點。 – 2014-10-11 18:46:40