Jafe Lee

            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
            49 隨筆 :: 0 文章 :: 24 評論 :: 0 Trackbacks
          因網(wǎng)絡(luò)課程的作業(yè)需要用到winpcap,不得已又要和C++打交道了。由于winpcap是為vc而設(shè)計(jì)的,但是我又不大喜歡用盜版,于是打算用免費(fèi)的 VC++ 2005 Express版。

          1、安裝 Visual Studio 2005 Express Edition 和 Paltform SDK。

          如何安裝Visual Studio 2005 Express在這里就不贅述了,很簡單的。由于VC Express沒有自帶 Platform SDK,所以需要自己下載安裝(如果不安裝 psdk的話,就會出現(xiàn) 找不到 winsock2.h 的編譯錯(cuò)誤)。由于微軟現(xiàn)在官網(wǎng)提供的psdk下載比較麻煩,需要windows正版驗(yàn)證,再加上體積比較大,所以我這里就不用,我用的psdk是在這里下載的:
          XPSP2 PSDK Full Download with Local Install
          還有一個(gè),不知道能不能安裝在xp上,有興趣的兄弟可以自己試試
          Windows Server 2003 PSDK Full Download with Local Install
          似乎這兩個(gè)鏈接在官網(wǎng)上是找不到的
          下載、解壓、安裝,然后再配置 VC++:
          tools --> options? --> Projects and Solutions? --> VC++ Directories?? : 把以下路徑添加到相應(yīng)的下拉節(jié)點(diǎn)中去:(其中psdk是你的sdk安裝目錄)
          • Executalbe files :psdkdir\Bin

          • Include files :psdkdir\include

          • Library files:psdkdir\lib

          2、安裝 winpcap:到這里下載 winpcap
          安裝后按要求重啟,如果沒安裝這個(gè)包,程序即使編譯成功也不能運(yùn)行,會提示找不到 winpcap.dll

          3、下載? WinPcap Developer's Packs
          解壓后會得一個(gè)目錄WpdPack四個(gè)子目錄:
          ?docs
          ?Examples-pcap
          ?Examples-remote
          ?Include
          ?Lib
          然后配置VC++
          tools --> options? --> Projects and Solutions? --> VC++ Directories :
          • Include files :WpdPackPath\include

          • Library files: WpdPackPath\lib

          其中 WpdPackPath是目錄WpdPack的絕對路徑

          4、新建一個(gè) win32->win32 console application 工程,然后配置工程屬性:
          • 右鍵 -> Properties -> Configuration Properties -> C/C++ -> Preprocessor -> Proprocessor Definition?? 往上面添加 WPCAP就可以了(這一步不做似乎也沒什么問題~)
          • 右鍵 -> Properties -> Configuration Properties -> Linker -> input -> Additional Dependencies? 往上面添加 wpcap.lib Packet.lib
          5、一個(gè)例子:
          注意,如果不添加 #include "remote-ext.h" 也是會報(bào)錯(cuò)的~

          6、鏈接錯(cuò)誤:
          anothertest.obj?:?error?LNK2019:?unresolved?external?symbol?__imp__WSASetLastError@4?referenced?in?function?_WspiapiGetNameInfo@28
          anothertest.obj?:?error?LNK2019:?unresolved?external?symbol?__imp__inet_ntoa@
          4?referenced?in?function?_WspiapiLegacyGetAddrInfo@16
          anothertest.obj?:?error?LNK2019:?unresolved?external?symbol?__imp__htonl@
          4?referenced?in?function?_WspiapiLegacyGetAddrInfo@16
          anothertest.obj?:?error?LNK2019:?unresolved?external?symbol?__imp__getservbyname@
          8?referenced?in?function?_WspiapiLegacyGetAddrInfo@16
          anothertest.obj?:?error?LNK2019:?unresolved?external?symbol?__imp__htons@
          4?referenced?in?function?_WspiapiLegacyGetAddrInfo@16
          anothertest.obj?:?error?LNK2019:?unresolved?external?symbol?__imp__inet_addr@
          4?referenced?in?function?_WspiapiParseV4Address@8
          anothertest.obj?:?error?LNK2019:?unresolved?external?symbol?__imp__WSAGetLastError@
          0?referenced?in?function?_WspiapiQueryDNS@24
          anothertest.obj?:?error?LNK2019:?unresolved?external?symbol?__imp__gethostbyname@
          4?referenced?in?function?_WspiapiQueryDNS@24
          anothertest.obj?:?error?LNK2019:?unresolved?external?symbol?__imp__gethostbyaddr@
          12?referenced?in?function?_WspiapiLegacyGetNameInfo@28
          anothertest.obj?:?error?LNK2019:?unresolved?external?symbol?__imp__getservbyport@
          8?referenced?in?function?_WspiapiLegacyGetNameInfo@28
          anothertest.obj?:?error?LNK2019:?unresolved?external?symbol?__imp__ntohs@
          4?referenced?in?function?_WspiapiLegacyGetNameInfo@28
          解決該問題,需要只需把ws2_32.lib添加到wpcap.lib Packet.lib后面(見上面第4條)
          posted on 2007-09-27 14:55 Jafe Lee 閱讀(2992) 評論(5)  編輯  收藏 所屬分類: C++

          評論

          # re: Visual Studio 2005 Express 下的 WinPcap 配置 2007-09-27 16:19 kingster
          閱,不會java
          以后學(xué)  回復(fù)  更多評論
            

          # re: Visual Studio 2005 Express 下的 WinPcap 配置 2007-09-27 18:14 Jafe
          @kingster
          暈,這不是 Java~
          網(wǎng)絡(luò)課的project要用winpcap,不得已用c++,sigh,我不用c++好多年,都忘了。。。  回復(fù)  更多評論
            

          # re: Visual Studio 2005 Express 下的 WinPcap 配置 2007-09-28 20:29 kingster
          不懂@@
          我啥都不會@@
          就會灌水  回復(fù)  更多評論
            

          # re: Visual Studio 2005 Express 下的 WinPcap 配置 2009-07-03 10:08 bunter
          請加入ws2_32.lib靜態(tài)庫  回復(fù)  更多評論
            

          # re: Visual Studio 2005 Express 下的 WinPcap 配置 2009-11-06 17:42 HeroBack
          哥們,謝謝~!  回復(fù)  更多評論
            


          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 宣武区| 扎赉特旗| 东宁县| 祁连县| 安龙县| 江西省| 华阴市| 满洲里市| 岚皋县| 永昌县| 乾安县| 合肥市| 灵璧县| 城口县| 佛山市| 古丈县| 西和县| 理塘县| 武宣县| 鱼台县| 红安县| 盱眙县| 密山市| 桃园县| 揭东县| 高碑店市| 思茅市| 新泰市| 林芝县| 阿拉善右旗| 图们市| 隆安县| 广河县| 广昌县| 富顺县| 夹江县| 潼关县| 洛浦县| 东乌| 酒泉市| 高雄县|