Jafe Lee

            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
            49 隨筆 :: 0 文章 :: 24 評(píng)論 :: 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的話,就會(huì)出現(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)行,會(huì)提示找不到 winpcap.dll

          3、下載? WinPcap Developer's Packs
          解壓后會(huì)得一個(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的絕對(duì)路徑

          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" 也是會(huì)報(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 閱讀(2986) 評(píng)論(5)  編輯  收藏 所屬分類: C++

          評(píng)論

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

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

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

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

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


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


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 姜堰市| 七台河市| 酒泉市| 武冈市| 水富县| 廊坊市| 仙桃市| 上高县| 龙山县| 翁源县| 分宜县| 巴林左旗| 镇巴县| 信丰县| 霍城县| 阳谷县| 股票| 宁都县| 思南县| 中阳县| 宜阳县| 广宁县| 宕昌县| 肃南| 兴和县| 东台市| 闽侯县| 织金县| 金阳县| 温泉县| 大连市| 读书| 体育| 天峻县| 潼南县| 肇庆市| 乌拉特前旗| 凉山| 江油市| 二连浩特市| 大石桥市|