[英]How to use Boost.Asio on Visual Studio 2005 - Windows Xp?
我必須在C ++ Visual Studio 2005(Windows XP)中使用庫Boost.asio。
我按照以下步驟操作:-我下載了可執行文件。 exe在我的文件路徑中的Windows XP上安裝Boost庫。
我設置環境變量INCLUDE:W:\\ boost_1_46_1(我的路徑文件中有庫)
在Visual Studio 2005中,在項目屬性(VS-> tools-> Options project&solutions-> vcc ++ directories)中,我添加了$(INCLUDE)
在Visual Studio項目的屬性中,我將庫的路徑添加到鏈接器以編譯示例。
我試圖編譯示例文件: http : //www.boost.org/doc/libs/1_46_1/doc/html/boost_asio/example/multicast/sender.cpp
編譯時出現幾個錯誤:
錯誤3錯誤C2653:'asio':不是類或名稱空間名稱c:\\ Documents and Settings \\ GG \\ Desktop \\ sender.cpp 2
錯誤4錯誤C2653:'asio':不是類或名稱空間名稱c:\\ Documents and Settings \\ GG \\ Desktop \\ sender.cpp 24
錯誤5錯誤C2143:語法錯誤:'&'c:\\ Documents and Settings \\ GG \\ Desktop \\ sender.cpp之前缺少')'24
錯誤6錯誤C2143:語法錯誤:缺少';' 在'&'c:\\ Documents and Settings \\ GG \\ Desktop \\ sender.cpp之前24
錯誤7錯誤C2460:'sender :: io_service':使用'sender',正在定義c:\\ Documents and Settings \\ GG \\ Desktop \\ sender.cpp 24
錯誤8錯誤C4430:缺少類型說明符-假定為int。 注意:C ++不支持default-int c:\\ Documents and Settings \\ GG \\ Desktop \\ sender.cpp 24
錯誤9錯誤C2653:'asio':不是類或名稱空間名稱c:\\ Documents and Settings \\ GG \\ Desktop \\ sender.cpp 24
錯誤10錯誤C2143:語法錯誤:缺少';' 在'&'c:\\ Documents and Settings \\ GG \\ Desktop \\ sender.cpp之前24
錯誤11錯誤C4430:缺少類型說明符-假定為int。 注意:C ++不支持default-int c:\\ Documents and Settings \\ GG \\ Desktop \\ sender.cpp 24
錯誤13錯誤C2059:語法錯誤:')'c:\\ Documents and Settings \\ GG \\ Desktop \\ sender.cpp 24
錯誤14錯誤C2065:'multicast_address':未聲明的標識符c:\\ Documents and Settings \\ GG \\ Desktop \\ sender.cpp 26
錯誤15錯誤C3861:'endpoint_':找不到標識符c:\\ Documents and Settings \\ GG \\ Desktop \\ sender.cpp 26
錯誤16錯誤C2531:'sender :: multicast_address':引用位域非法c:\\ Documents and Settings \\ GG \\ Desktop \\ sender.cpp 26
錯誤17錯誤C4430:缺少類型說明符-假定為int。 注意:C ++不支持default-int c:\\ Documents and Settings \\ GG \\ Desktop \\ sender.cpp 26
錯誤18錯誤C2327:'sender :: io_service':不是類型名稱,靜態或枚舉器c:\\ Documents and Settings \\ GG \\ Desktop \\ sender.cpp 27
錯誤19錯誤C2061:語法錯誤:標識符'io_service'c:\\ Documents and Settings \\ GG \\ Desktop \\ sender.cpp 27
錯誤20錯誤C2059:語法錯誤:')'c:\\ Documents and Settings \\ GG \\ Desktop \\ sender.cpp 27
錯誤21錯誤C2061:語法錯誤:標識符'timer_'c:\\ Documents and Settings \\ GG \\ Desktop \\ sender.cpp 28
錯誤22錯誤C2143:語法錯誤:'{'c:\\ Documents and Settings \\ GG \\ Desktop \\ sender.cpp前缺少')'30
錯誤23錯誤C4430:缺少類型說明符-假定為int。 注意:C ++不支持default-int c:\\ Documents and Settings \\ GG \\ Desktop \\ sender.cpp 30
錯誤24錯誤C2143:語法錯誤:缺少';' 在'{'c:\\ Documents and Settings \\ GG \\ Desktop \\ sender.cpp之前39
錯誤25錯誤C2334:“ {”之前的意外標記; 跳過明顯的函數正文c:\\ Documents and Settings \\ GG \\ Desktop \\ sender.cpp 39
錯誤26致命錯誤C1004:發現意外的文件結尾c:\\ Documents and Settings \\ GG \\ Desktop \\ sender.cpp 100
我錯過了一步嗎? 謝謝
現在,我在示例文件sender.cpp中添加了以下內容:
#using namespace boost;
現在,錯誤減少如下:
錯誤3錯誤C2039:'error_code':不是'boost :: asio'的成員c:\\ Documents and Settings \\ GG \\ Desktop \\ sender.cpp 42
錯誤4錯誤C4430:缺少類型說明符-假定為int。 注意:C ++不支持default-int c:\\ Documents and Settings \\ GG \\ Desktop \\ sender.cpp 42
錯誤5錯誤C2143:語法錯誤:在&&之前缺少','c:\\ Documents and Settings \\ GG \\ Desktop \\ sender.cpp 42
錯誤6錯誤C2039:'error_code':不是'boost :: asio'的成員c:\\ Documents and Settings \\ GG \\ Desktop \\ sender.cpp 53
錯誤7錯誤C4430:缺少類型說明符-假定為int。 注意:C ++不支持default-int c:\\ Documents and Settings \\ GG \\ Desktop \\ sender.cpp 53
錯誤8錯誤C2143:語法錯誤:'&'前缺少','c:\\ Documents and Settings \\ GG \\ Desktop \\ sender.cpp 53
錯誤9錯誤C2065:'錯誤':未聲明的標識符c:\\ Documents and Settings \\ GG \\ Desktop \\ sender.cpp 44
聽起來您已經完成了所有步驟。
如果在VS中的#include上單擊鼠標右鍵,然后打開include,它會找到並打開asio頭文件嗎? 這將是您VS環境是否正確設置的第一個指示。
我還將檢查boost是否已正確安裝:如果您選擇W:\\ boost_1_46_1作為安裝目錄(通常默認為C:\\ Program Files \\ boost之類的文件),請檢查
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.