2016-02-27 68 views
0

我想在此網頁中製作PCA-SIFT代碼(pcasift-0.91nd.tar.gz):http://www.cs.cmu.edu/~yke/pcasift/。運行./configure這是確定後,make命令報告認爲,C編譯器找不到頭pgm.h:如何在製作PCA-SIFT代碼時指定pgm庫的include和lib路徑

image.cc:18:22: fatal error: pgm.h: No such file or directory #include ^compilation terminated.

有一個在互聯網當中討論過這個問題網頁:http://ubuntuforums.org/showthread.php?t=1918422。最後陳述了一個解決方案:

Apparently, the header files are in the directory /usr/include/pgm-5.1 - the preferred way to get this into your include directories when compiling is to use pkgconfig. You will need to add something like pkg-config --cflags openpgm-5.1 at the end of your compilation command to get the right headers and add pkg-config --libs openpgm-5.1 to your linking command.

,但我無法理解它。具體來說,「在編譯命令末尾添加pkg-config --cflags openpgm-5.1」是什麼意思?我應該怎麼做,從字面上添加pkg-config --cflags openpgm-5.1或該命令在終端中返回的結果?並添加到什麼文件? Makefile由./configure生成。我應該添加到Makefile還是./configure?我已經成功安裝了libpgm-dev,它們確實在/usr/include/pgm-5.1中。命令pkg-config --cflags openpgm-5.1返回-I/usr/include/pgm-5.1 -I/usr/lib/x86_64-linux-gnu/pgm-5.1/include並且命令pkg-config --libs openpgm-5.1返回-lpgm -lpthread -lm

由於該線程已關閉,因此我必須在此處詢問。希望有人熟悉Linux編譯過程可以幫助我解決這個問題。非常感謝。

回答

1

我自己解決了這個問題。

原始問題中提到的ubuntuforums.org網頁中的所有內容都是錯誤的;這就是我遇到這麼多問題的原因。

錯誤1:使用sudo apt-get install libpgm-dev安裝libpgm-dev是錯誤的。 我們應該解壓下載後的NetPBM,並運行以下命令:

./configure  //type none on prompt if you don't have JPEG, TIFF, etc. libraries 
make 
sudo make package pkgdir=netpbmpkg 
sudo ./installnetpbm 
sudo rm -f -r /netpbmpkg/ 

隨後的NetPBM安裝在Ubuntu上。

錯誤2.包括由pkg-config --cflags返回的路徑是錯誤的

默認情況下,包括路徑應和/usr/local/netpbm/include和庫路徑是/usr/local/netpbm/lib

錯誤3. pkg-config --libs返回的鏈接選項-lpgm是錯誤的

正確的連接選項應該是-lnetpbm

遵循正確的方法,我可以在Netbeans中成功編譯項目(忘記命令行make)。

+0

嘿我正面臨同樣的問題你能告訴我該怎麼做這行應該執行「sudo make package pkgdir = netpbmpkg」我不知道該輸入什麼。你還提到什麼是錯的,你能告訴如何設置它是正確的,或者如果你能指出任何詳細的過程,那也不錯。 –