Jafe Lee

            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
            49 隨筆 :: 0 文章 :: 24 評論 :: 0 Trackbacks
          因網(wǎng)絡(luò)課程的作業(yè)需要用到winpcap,不得已又要和C++打交道了。由于winpcap是為vc而設(shè)計的,但是我又不大喜歡用盜版,于是打算用免費(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 的編譯錯誤)。由于微軟現(xiàn)在官網(wǎng)提供的psdk下載比較麻煩,需要windows正版驗證,再加上體積比較大,所以我這里就不用,我用的psdk是在這里下載的:
          XPSP2 PSDK Full Download with Local Install
          還有一個,不知道能不能安裝在xp上,有興趣的兄弟可以自己試試
          Windows Server 2003 PSDK Full Download with Local Install
          似乎這兩個鏈接在官網(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
          安裝后按要求重啟,如果沒安裝這個包,程序即使編譯成功也不能運(yùn)行,會提示找不到 winpcap.dll

          3、下載? WinPcap Developer's Packs
          解壓后會得一個目錄WpdPack四個子目錄:
          ?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、新建一個 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、一個例子:
          注意,如果不添加 #include "remote-ext.h" 也是會報錯的~

          6、鏈接錯誤:
          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 閱讀(2995) 評論(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)航:
           
          主站蜘蛛池模板: 威宁| 东乡县| 年辖:市辖区| 中方县| 静乐县| 华坪县| 肥乡县| 龙井市| 忻城县| 蓬安县| 万盛区| 曲麻莱县| 隆林| 秀山| 沙湾县| 东城区| 广河县| 绵阳市| 吴忠市| 夹江县| 临邑县| 柳林县| 凉山| 永兴县| 福海县| 登封市| 静安区| 千阳县| 余姚市| 德令哈市| 碌曲县| 建德市| 孟津县| 高陵县| 永年县| 大同县| 涞水县| 睢宁县| 宁强县| 武山县| 合作市|