我正在編譯Visual Studio 2015 Community Edition中的以下程序。在Visual Studio 2015中使用Npcap編譯VC++程序
#include "stdafx.h"
#include <stdlib.h>
#include <stdio.h>
#include <pcap.h>
int main(int argc, char **argv)
{
pcap_if_t *alldevsp, *device;
char errbuf[100];
int count = 1;
//First get the list of available devices
printf("Finding available devices ... ");
if (pcap_findalldevs(&alldevsp, errbuf))
{
printf("Error finding devices : %s", errbuf);
exit(1);
}
printf("Done");
//Print the available devices
printf("\nAvailable Devices are :\n");
for (device = alldevsp; device != NULL; device = device->next)
{
printf("%d. %s - %s\n", count, device->name, device->description);
count++;
}
return 0;
}
對於pcap我已經從Npcap project @ GitHub下載了庫。 我安裝了用於獲取DLL和使用SDK庫的頭文件和鏈接庫的版本。 DLL的安裝來自發行包0.0.8-r2,並且SDK從0.0.7-r9發行。
以下幾個指針在網絡上如何設置環境,我有以下設置。
- 配置屬性 - > C/C++ - >常規 - >其他包含目錄 - > SDK的頭文件夾路徑。
- 配置屬性 - > C/C++ - >預處理器 - >預處理定義 - > WIN32 _DEBUG _CONSOLE WPCAP HAVE_REMOTE
- 配置屬性 - >鏈接器 - >常規 - >附加庫目錄 - >路徑從SDK庫文件夾。
- 配置屬性 - >鏈接器 - >輸入 - >附加依賴 - >自發布EXE wpcap.lib PACKET.LIB
DLL被安裝在C:\ WINDOWS \ SYSTEM32 \ Npcap。 系統是Windows 10 Home。
問:
上述程序編譯罰款。
1>------ Build started: Project: HelloWorld, Configuration: Debug Win32 ------
1> HelloWorld.cpp
1> HelloWorld.vcxproj -> C:\Users\xxx\documents\visual studio 2015\Projects\HelloWorld\Debug\HelloWorld.exe
1> HelloWorld.vcxproj -> C:\Users\xxx\documents\visual studio 2015\Projects\HelloWorld\Debug\HelloWorld.pdb (Full PDB)
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
當我運行它時,它抱怨缺少wpcap.dll文件。我是VS新手,還有VC++,我用Google搜索和最簡單的技術來解決這個問題,我將DLL從System32複製到生成.exe文件的文件夾中。
此DLL問題消失後,但現在我越來越。
'HelloWorld.exe' (Win32): Loaded 'C:\Users\xxx\Documents\Visual Studio 2015\Projects\HelloWorld\Debug\HelloWorld.exe'. Symbols loaded.
'HelloWorld.exe' (Win32): Loaded 'C:\Windows\syswow64\ntdll.dll'. Cannot find or open the PDB file.
'HelloWorld.exe' (Win32): Loaded 'C:\Windows\syswow64\kernel32.dll'. Cannot find or open the PDB file.
'HelloWorld.exe' (Win32): Loaded 'C:\Windows\syswow64\KernelBase.dll'. Cannot find or open the PDB file.
'HelloWorld.exe' (Win32): Loaded 'C:\Windows\syswow64\ucrtbased.dll'. Cannot find or open the PDB file.
'HelloWorld.exe' (Win32): Loaded 'C:\Windows\syswow64\vcruntime140d.dll'. Cannot find or open the PDB file.
The thread 0x160c has exited with code -1073741701 (0xc000007b).
The thread 0xd5c has exited with code -1073741701 (0xc000007b).
The thread 0x16c4 has exited with code -1073741701 (0xc000007b).
The program '[9632] HelloWorld.exe' has exited with code -1073741701 (0xc000007b).
我使用它,它似乎有64位和32位DLL的混合。我不知道如何開始調試這個問題。
我真的很感激,如果有人指導我解決。
- 更好的方法(在VC++世界的良好做法)找到DLL而不是複製到exe文件夾。
- 有關如何找到哪個DLL導致問題的提示。
謝謝你的時間。
非常感謝您看看它,它解決了這個問題 –