[Winpcap-users] Error compiling WinPcap based applications by using Visual C++ 2008

Chin Shi Hong cshong87 at gmail.com
Tue Jun 1 22:01:58 PDT 2010


On Wed, Jun 2, 2010 at 7:10 AM, Kyle Brotheridge <kyle at connecttel.com.au>wrote:

> Chin Shi Hong ,
>
>
>
> I’ve copied the sample code from
> http://www.winpcap.org/docs/docs_411/html/group__wpcap__tut3.html and it
> works fine...
>
>
>
> The difference is:
>
> -          I’m using Visual Studio 2008 Professional (Not Visual C++
> Express edition)
>
> -          I created an empty Windows Console project (no precompiled
> header or stdafx files)
>
> -          I added 1 file: test.cpp
>
> -          I followed most of the steps under the heading “*Visual Studio
> 2005 (needed to compile x64 applications” * in
> http://www.winpcap.org/docs/docs_411/html/group__wpcapsamps.html
>
> o   I didn’t add the pre-processor definitions
>
> o   I just added extra the extra include directories and extra library
> dirs..
>
>
>
> Perhaps start the project again, copy the code into a single test.cpp file
> like I have done (AND DON’T ALTER IT) and if it still doesn’t work I’d be
> definitely pointing at the “Express Edition” as the cause of those errors,
> probably due to limited functionality of that edition.
>
>
>
> -KB
>
>
>
> *From:* winpcap-users-bounces at winpcap.org [mailto:
> winpcap-users-bounces at winpcap.org] *On Behalf Of *Chin Shi Hong
> *Sent:* Tuesday, 1 June 2010 5:05 PM
>
> *To:* winpcap-users at winpcap.org
> *Subject:* Re: [Winpcap-users] Error compiling WinPcap based applications
> by using Visual C++ 2008
>
>
>
> On Mon, May 31, 2010 at 9:52 AM, Kyle Brotheridge <kyle at connecttel.com.au>
> wrote:
>
> Do you #include <pcap.h> first?
>
> You shouldn't need to include any other WinPCAP header other than the
> above, my project compiles fine and uses the headers in the following order:
>
> #pragma region Includes and Libs
> // Disable CRT warnings on functions that are now deemed 'unsafe'
> #define _CRT_SECURE_NO_WARNINGS
>
> #include <pcap.h>
> #include <winsock.h>
> #include <iphlpapi.h>
> #include <stdio.h>
>
> // Non-standard LIBs to include
> #pragma comment(lib, "wpcap.lib")
> #pragma comment(lib, "packet.lib")
> #pragma comment(lib, "ws2_32.lib")
> #pragma comment(lib, "iphlpapi.lib")
> #pragma endregion
>
> -KB
>
>
> ---------------
>
> From: winpcap-users-bounces at winpcap.org [mailto:
> winpcap-users-bounces at winpcap.org] On Behalf Of Chin Shi Hong
> Sent: Sunday, 30 May 2010 3:36 PM
> To: winpcap-users at winpcap.org
> Subject: [Winpcap-users] Error compiling WinPcap based applications by
> using Visual C++ 2008
>
>
> Dear all,
>
> I am new to WinPcap, I had followed the instructions showed at
> http://www.winpcap.org/docs/docs_411/html/group__wpcapsamps.html . When I
> try to compile the codes I get from
> http://www.winpcap.org/docs/docs_411/html/group__wpcap__tut3.html , by
> using Visual C++ 2008 Express Edition on Windows 7 Home Premium 64-bit
> edition, I get the following errors:
>
> 1>------ Build started: Project: network, Configuration: Debug Win32 ------
> 1>Compiling...
> 1>network.cpp
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\bpf.h(68) : error C2146:
> syntax error : missing ';' before identifier 'bpf_u_int32'
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\bpf.h(68) : error C4430:
> missing type specifier - int assumed. Note: C++ does not support default-int
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\bpf.h(68) : error C4430:
> missing type specifier - int assumed. Note: C++ does not support default-int
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\bpf.h(105) : error C2146:
> syntax error : missing ';' before identifier 'bv_major'
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\bpf.h(105) : error C4430:
> missing type specifier - int assumed. Note: C++ does not support default-int
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\bpf.h(105) : error C4430:
> missing type specifier - int assumed. Note: C++ does not support default-int
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\bpf.h(106) : error C2146:
> syntax error : missing ';' before identifier 'bv_minor'
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\bpf.h(106) : error C4430:
> missing type specifier - int assumed. Note: C++ does not support default-int
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\bpf.h(106) : error C4430:
> missing type specifier - int assumed. Note: C++ does not support default-int
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\bpf.h(905) : error C2146:
> syntax error : missing ';' before identifier 'code'
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\bpf.h(905) : error C4430:
> missing type specifier - int assumed. Note: C++ does not support default-int
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\bpf.h(905) : error C4430:
> missing type specifier - int assumed. Note: C++ does not support default-int
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\bpf.h(906) : error C2146:
> syntax error : missing ';' before identifier 'jt'
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\bpf.h(906) : error C4430:
> missing type specifier - int assumed. Note: C++ does not support default-int
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\bpf.h(906) : error C4430:
> missing type specifier - int assumed. Note: C++ does not support default-int
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\bpf.h(907) : error C2146:
> syntax error : missing ';' before identifier 'jf'
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\bpf.h(907) : error C4430:
> missing type specifier - int assumed. Note: C++ does not support default-int
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\bpf.h(907) : error C4430:
> missing type specifier - int assumed. Note: C++ does not support default-int
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\bpf.h(908) : error C2146:
> syntax error : missing ';' before identifier 'k'
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\bpf.h(908) : error C4430:
> missing type specifier - int assumed. Note: C++ does not support default-int
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\bpf.h(908) : error C4430:
> missing type specifier - int assumed. Note: C++ does not support default-int
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\bpf.h(919) : error C4430:
> missing type specifier - int assumed. Note: C++ does not support default-int
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\bpf.h(919) : error C2143:
> syntax error : missing ',' before '*'
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\pcap.h(130) : error C2146:
> syntax error : missing ';' before identifier 'magic'
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\pcap.h(130) : error C4430:
> missing type specifier - int assumed. Note: C++ does not support default-int
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\pcap.h(130) : error C4430:
> missing type specifier - int assumed. Note: C++ does not support default-int
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\pcap.h(131) : error C2146:
> syntax error : missing ';' before identifier 'version_major'
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\pcap.h(131) : error C4430:
> missing type specifier - int assumed. Note: C++ does not support default-int
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\pcap.h(131) : error C4430:
> missing type specifier - int assumed. Note: C++ does not support default-int
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\pcap.h(132) : error C2146:
> syntax error : missing ';' before identifier 'version_minor'
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\pcap.h(132) : error C4430:
> missing type specifier - int assumed. Note: C++ does not support default-int
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\pcap.h(132) : error C4430:
> missing type specifier - int assumed. Note: C++ does not support default-int
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\pcap.h(134) : error C2146:
> syntax error : missing ';' before identifier 'sigfigs'
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\pcap.h(134) : error C4430:
> missing type specifier - int assumed. Note: C++ does not support default-int
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\pcap.h(134) : error C4430:
> missing type specifier - int assumed. Note: C++ does not support default-int
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\pcap.h(135) : error C2146:
> syntax error : missing ';' before identifier 'snaplen'
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\pcap.h(135) : error C4430:
> missing type specifier - int assumed. Note: C++ does not support default-int
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\pcap.h(135) : error C4430:
> missing type specifier - int assumed. Note: C++ does not support default-int
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\pcap.h(136) : error C2146:
> syntax error : missing ';' before identifier 'linktype'
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\pcap.h(136) : error C4430:
> missing type specifier - int assumed. Note: C++ does not support default-int
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\pcap.h(136) : error C4430:
> missing type specifier - int assumed. Note: C++ does not support default-int
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\pcap.h(168) : error C2079:
> 'pcap_pkthdr::ts' uses undefined struct 'timeval'
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\pcap.h(169) : error C2146:
> syntax error : missing ';' before identifier 'caplen'
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\pcap.h(169) : error C4430:
> missing type specifier - int assumed. Note: C++ does not support default-int
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\pcap.h(169) : error C4430:
> missing type specifier - int assumed. Note: C++ does not support default-int
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\pcap.h(170) : error C2146:
> syntax error : missing ';' before identifier 'len'
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\pcap.h(170) : error C4430:
> missing type specifier - int assumed. Note: C++ does not support default-int
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\pcap.h(170) : error C4430:
> missing type specifier - int assumed. Note: C++ does not support default-int
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\pcap.h(228) : error C2146:
> syntax error : missing ';' before identifier 'flags'
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\pcap.h(228) : error C4430:
> missing type specifier - int assumed. Note: C++ does not support default-int
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\pcap.h(228) : error C4430:
> missing type specifier - int assumed. Note: C++ does not support default-int
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\pcap.h(244) : error C2065:
> 'u_char' : undeclared identifier
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\pcap.h(244) : error C2059:
> syntax error : ','
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\pcap.h(272) : error C2061:
> syntax error : identifier 'bpf_u_int32'
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\pcap.h(299) : error C2061:
> syntax error : identifier 'pcap_handler'
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\pcap.h(300) : error C2061:
> syntax error : identifier 'pcap_handler'
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\pcap.h(301) : error C4430:
> missing type specifier - int assumed. Note: C++ does not support default-int
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\pcap.h(301) : error C2143:
> syntax error : missing ';' before '*'
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\pcap.h(302) : error C4430:
> missing type specifier - int assumed. Note: C++ does not support default-int
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\pcap.h(303) : error C4430:
> missing type specifier - int assumed. Note: C++ does not support default-int
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\pcap.h(303) : error C2143:
> syntax error : missing ',' before '*'
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\pcap.h(311) : error C4430:
> missing type specifier - int assumed. Note: C++ does not support default-int
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\pcap.h(311) : error C2143:
> syntax error : missing ',' before '*'
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\pcap.h(317) : error C2061:
> syntax error : identifier 'bpf_u_int32'
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\pcap.h(319) : error C2061:
> syntax error : identifier 'bpf_u_int32'
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\pcap.h(322) : error C4430:
> missing type specifier - int assumed. Note: C++ does not support default-int
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\pcap.h(322) : error C2143:
> syntax error : missing ',' before '*'
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\pcap.h(346) : error C2059:
> syntax error : ','
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\pcap.h(354) : error C4430:
> missing type specifier - int assumed. Note: C++ does not support default-int
> 1>c:\files\wpdpack_4_1_1\wpdpack\include\pcap\pcap.h(354) : error C2143:
> syntax error : missing ',' before '*'
> 1>c:\users\user\documents\visual studio
> 2008\projects\network\network\network.cpp(4) : error C2065: 'param' :
> undeclared identifier
> 1>c:\users\user\documents\visual studio
> 2008\projects\network\network\network.cpp(4) : error C2059: syntax error :
> 'const'
> 1>c:\users\user\documents\visual studio
> 2008\projects\network\network\network.cpp(19) : error C3861: 'exit':
> identifier not found
> 1>c:\users\user\documents\visual studio
> 2008\projects\network\network\network.cpp(74) : error C2065:
> 'packet_handler' : undeclared identifier
> 1>c:\users\user\documents\visual studio
> 2008\projects\network\network\network.cpp(81) : error C2065: 'param' :
> undeclared identifier
> 1>c:\users\user\documents\visual studio
> 2008\projects\network\network\network.cpp(81) : error C2059: syntax error :
> 'const'
> 1>c:\users\user\documents\visual studio
> 2008\projects\network\network\network.cpp(82) : error C2143: syntax error :
> missing ';' before '{'
> 1>c:\users\user\documents\visual studio
> 2008\projects\network\network\network.cpp(82) : error C2447: '{' : missing
> function header (old-style formal list?)
> 1>Build log was saved at "file://c:\Users\user\Documents\Visual Studio
> 2008\Projects\network\network\Debug\BuildLog.htm"
> 1>network - 78 error(s), 0 warning(s)
> ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
>
> How to solve it?
>
> _______________________________________________
> Winpcap-users mailing list
> Winpcap-users at winpcap.org
> https://www.winpcap.org/mailman/listinfo/winpcap-users
>
>
>
> I did include the header file. I just copy and paste the source code from
> http://www.winpcap.org/docs/docs_411/html/group__wpcap__tut3.html to
> visual c++. The source code on that website only include pcap.h header file.
>
> _______________________________________________
> Winpcap-users mailing list
> Winpcap-users at winpcap.org
> https://www.winpcap.org/mailman/listinfo/winpcap-users
>
>
Not related to express edition.

I solved the errors by adding winsock2.h. However, another problem occurred
while running the program. I will post it in another message.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.winpcap.org/pipermail/winpcap-users/attachments/20100602/9583a563/attachment-0001.htm 


More information about the Winpcap-users mailing list