几天前,有个朋友跟我探讨怎么从网卡上抓数据包,找了找资料,发现了WinPcap库。WinPcap是unix下libpcap的windows版,它是从TCP/IP协议的连接层抓包,工业标准级的开源库。
下载和安装都很容易,先找了一个Example下的例子编译,发现有COFF和OMF的问题,C++Builder不支持VC的COFF格式的LIB,先用BCB自带的coff2omf转换
coff2omf -v -lib:ms wpcap.lib wpcap_o.lib
coff2omf -v -lib:ms Packet.lib Packet_o.lib
再编译链接就OK了。



Kevin said
Hi, my name is Kevin, nice to meet you!
I am a rookie in Borland C++builder programming so may i ask how did u actually run WinPcap using C++ builder? I converted the libary to COFF version but its the “pcap.h” file that is giving me all the errors.
Any suggestions will be grateful, thank you for your time.
Kevin
lihui said
YES, I use WinPcap in C++ Builder very well.
For your questions, you could write the error messages here or via email.
cz_lh [at] msn dot com
Charles
Kevin said
Good day, Charles,
Thank you so much for you quick reply, i have been spending whole day trying to solve my situation here and unfortunately i am getting no where. i am deeply grateful for your assistance.
I first want to apologize for all these newbie questions; i have some experience in borland C++ but not with WinPcap and Microsoft Visual C++.
Ok, i have tried the couple things already…
0. Before diving into the source code and confused myself, i decided to start with the example that WinPcap provided, the example on reading the offline dump file to be exact (examples-pcap\readfile).
1. Then i used the “Visual C++ Project conversion utility” under the “Tools” option in Borland C++ program to convert the example into borland C++ project.
2. I also used the coff2omf command to convert the libaries into borland c++ format and then i added the new paths for the libraries and include files from the “Directories” in borland C++.
3. However, i got the following warning messages and an error message when i tried to build the project:
[C++ Warning] wspiapi.h(786): W8060 Possibly incorrect assignment
[C++ Warning] wspiapi.h(866): W8061 Initialization is only partially bracketed
[C++ Warning] wspiapi.h(866): W8061 Initialization is only partially bracketed
[C++ Warning] wspiapi.h(866): W8061 Initialization is only partially bracketed
[C++ Warning] wspiapi.h(871): W8061 Initialization is only partially bracketed
[C++ Warning] wspiapi.h(871): W8061 Initialization is only partially bracketed
[C++ Warning] wspiapi.h(871): W8061 Initialization is only partially bracketed
[Linker Error] Unresolved external ‘_wmain’ referenced from C:\PROGRAM FILES\BORLAND\CBUILDER6\LIB\C0X32W.OBJ
4. Therefore, may i ask what do i have to do in order to build the example successfully and make it work so i can read a dump file?
Thank you so much again and wish you have a nice day.
Kind Regards,
Kevin
lihui said
Check your email
Mac said
hey guys, show us the answer…