如何編譯並運行“protoident”

如何編譯並運行“protoident”

我正在嘗試編譯並運行一個名為的開源 DPI 工具原型。所以我下載了其原始碼來自Github並在目錄中搜尋編譯/建置手冊,但我什麼也沒找到。最後我開始在其目錄中運行make命令和Makefile命令,但我遇到了以下錯誤:

me@me-MS-7693:~/Desktop/protoident-master/src$ ./Makefile 
./Makefile: line 9: TARGET: command not found
./Makefile: line 10: PROTOCOLS: command not found
./Makefile: line 11: PROTOCOLS: command not found
./Makefile: line 11: SOURCES: command not found
./Makefile: line 12: SOURCES:.c=.h: command not found
./Makefile: line 12: HEADERS: command not found
./Makefile: line 13: SOURCES:.c=.o: command not found
./Makefile: line 13: OBJECTS: command not found
./Makefile: line 14: OTHER_FILES: command not found
./Makefile: line 18: CC: command not found
./Makefile: line 19: CFLAGS: command not found
./Makefile: line 21: OFLAG: command not found
./Makefile: line 22: CFLAG: command not found
./Makefile: line 24: CC: command not found
./Makefile: line 24: LINK: command not found
./Makefile: line 25: LINKFLAGS: command not found
./Makefile: line 26: LIBS: command not found
./Makefile: line 31: .SUFFIXES:: command not found
./Makefile: line 32: .c.o:: command not found
./Makefile: line 33: CC: command not found
./Makefile: line 33: CFLAGS: command not found
./Makefile: line 33: CFLAG: command not found
./Makefile: line 33: OFLAG: command not found
./Makefile: line 33: $<: command not found
./Makefile: line 38: SOURCES: command not found
./Makefile: line 38: TARGET: command not found
./Makefile: line 38: all:: command not found
./Makefile: line 40: profile:: command not found
./Makefile: line 41: profile_compile:: command not found
./Makefile: line 42: profile_compile:: command not found
./Makefile: line 43: profile_compile:: command not found
./Makefile: line 46: TARGET: command not found
./Makefile: line 46: OBJECTS: command not found
./Makefile: line 47: LINK: command not found
./Makefile: line 47: LINKFLAGS: command not found
./Makefile: line 47: LIBS: command not found
./Makefile: line 47: OFLAG: command not found
./Makefile: line 47: TARGET: command not found
./Makefile: line 47: OBJECTS: command not found
./Makefile: line 52: archive:: command not found
./Makefile: line 53: TARGET: command not found
./Makefile: line 53: SOURCES: command not found
./Makefile: line 53: HEADERS: command not found
./Makefile: line 53: OTHER_FILES: command not found
tar: Cowardly refusing to create an empty archive
Try 'tar --help' or 'tar --usage' for more information.
./Makefile: line 55: clean:: command not found
./Makefile: line 56: OBJECTS: command not found
./Makefile: line 58: distclean:: command not found
./Makefile: line 59: TARGET: command not found


me@me-MS-7693:~/Desktop/protoident-master/src$ make
gcc  -lpcap -o protoident main.o hashtable.o ip_reassembling.o flow.o global_func.o dns.o http.o sip.o smtp.o
main.o: In function `main':
/home/ghasemi/Desktop/protoident-master/src/main.c:85: undefined reference to `pcap_open_offline'
/home/ghasemi/Desktop/protoident-master/src/main.c:97: undefined reference to `pcap_compile'
/home/ghasemi/Desktop/protoident-master/src/main.c:100: undefined reference to `pcap_geterr'
/home/ghasemi/Desktop/protoident-master/src/main.c:103: undefined reference to `pcap_setfilter'
/home/ghasemi/Desktop/protoident-master/src/main.c:105: undefined reference to `pcap_geterr'
/home/ghasemi/Desktop/protoident-master/src/main.c:118: undefined reference to `pcap_datalink'
/home/ghasemi/Desktop/protoident-master/src/main.c:125: undefined reference to `pcap_loop'
/home/ghasemi/Desktop/protoident-master/src/main.c:134: undefined reference to `pcap_freecode'
/home/ghasemi/Desktop/protoident-master/src/main.c:136: undefined reference to `pcap_close'
collect2: error: ld returned 1 exit status
Makefile:47: recipe for target 'protoident' failed
make: *** [protoident] Error 1

為什麼我會遇到這些錯誤以及如何編譯和使用這個工具?

答案1

Makefile是 的設定文件make,而不是單獨的命令。規範的建置和安裝過程是:

./configure
make
make install   # usually: sudo make install

README大多數項目在文字檔案或類似檔案中詳細描述了其安裝過程INSTALL

然而,這個沒有任何configure腳本,而是有一個現成的腳本Makefile。它不包含INSTALL節,因此第三個命令也不適用。

所以你只需要運行:

make

它記錄在目錄README中的文件中src。有趣的是它是用捷克語寫的(順便說一下,這是我的母語)。

修復undefined reference錯誤

提供的 Makefile 中有一個問題,可以使用以下補丁修復(基於堆疊溢位評論):

diff --git a/src/Makefile b/src/Makefile
index 367dcc4..dda5fb3 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -44,7 +44,7 @@ profile_compile: all


 $(TARGET): $(OBJECTS)
-       $(LINK) $(LINKFLAGS) $(LIBS) $(OFLAG) $(TARGET) $(OBJECTS)
+       $(LINK) $(LINKFLAGS) $(OFLAG) $(TARGET) $(OBJECTS) $(LIBS)

 #####################################
 #other rules

答案2

我查看了您的連結以獲取說明。它們可以找到,但是用捷克語寫的。例如:

Zdrojová a cílová síťová adresa, zdrojový a cílový port není třeba dále
vysvětlovat.

翻譯成英文如下:

Source and destination network address, source and destination port does not need to be further explain.

查看各種來源文件,您會在描述中看到“未測試”。

作者稱該計畫是實驗,已經兩年沒有更新了。

我建議專案已損壞,您的編譯器和 make 函數可能沒有任何問題。要確認您的系統正常運作,請從 github 下載一個適用於 gnome 桌面的簡單計算器,該計算器有 200 個貢獻者和 243 個版本:gnome 計算器。編譯這個,而不是你目前選擇的兩年沒有任何活動,被作者稱為實驗的東西。

相關內容