我正在尝试在此网页中制作 PCA-SIFT 代码 (pcasift-0.91nd.tar.gz):http://www.cs.cmu.edu/~yke/pcasift/ .运行 ./configure 后 OK,make 命令报告 C 编译器找不到头文件 pgm.h:
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 addpkg-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 编译过程的人可以帮助我解决这个问题。非常感谢。
最佳答案
我自己解决了这个问题。
原问题中提到的 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/
然后在 Ubuntu 上安装了 Netpbm。
错误2.pkg-config --cflags
返回的include路径错误
默认包含路径为/usr/local/netpbm/include
,lib路径为/usr/local/netpbm/lib
。
错误 3.pkg-config --libs
返回的链接选项-lpgm
错误
正确的链接选项应该是-lnetpbm
。
按照正确的方法,我可以在Netbeans中成功编译项目(忘记命令行make)。
关于linux - 制作PCA-SIFT代码时如何指定pgm库的include和lib路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35667178/