Windows C++ IDE 教學 – C++ Socket Programming

Author: Eric  //  Category: Free Teaching

01. 使用 Code::Blocks 寫 Socket Program 的設定

Settings -> Compiler and debugger -> Linker Settings -> Other linker options -> 加上 -lws2_32

02. 使用 Dev C++ 寫 Socket Program 的設定

Tools -> Compiler Options -> 打勾 Add these commands to linker command line -> 加上 -lws2_32

03. 使用 Microsoft Visual C++ 6.0 寫 Socket Program 的設定。// 以下方法擇一即可

a. 程式碼前面加上 #pragma comment(lib, "wsock32.lib")

b. Project -> Settings -> Link -> Object/library modules -> 最後加上 ws2_32.lib

Tags: , , , ,

2 Responses to “Windows C++ IDE 教學 – C++ Socket Programming”

  1. CJ Says:

    您好~若用VS2008該如何LINK?謝謝!

  2. Eric Says:

    1. 程式碼加 # include <winsock2.h>
    2. 程式碼加 # pragma comment( lib, "ws2_32.lib" )

    或 Solution Explorer -> Project Name 按右鍵 -> Configuration Properties -> Linker -> Command Line 的 Additional options 加 ws2_32.lib

Leave a Reply