制作PCA-SIFT代码时如何指定pgm库的include和lib路径

How to specify the include and lib path of pgm library when making PCA-SIFT code

我正在尝试在此网页中制作 PCA-SIFT 代码 (pcasift-0.91nd.tar.gz):http://www.cs.cmu.edu/~yke/pcasift/。 运行 ./configure which OK后make命令报C编译器找不到header 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 add pkg-config --libs openpgm-5.1 to your linking command.

,但我看不懂。具体来说,"add pkg-config --cflags openpgm-5.1 at the end of your compilation command" 是什么意思?我应该怎么做,从字面上添加 pkg-config --cflags openpgm-5.1 或在终端中添加此命令 returns 的结果?并添加到什么文件? Makefile 由./configure 生成。我应该添加到 Makefile 还是 ./configure?我已成功安装 libpgm-dev,它们确实在 /usr/include/pgm-5.1 中。命令 pkg-config --cflags openpgm-5.1 returns -I/usr/include/pgm-5.1 -I/usr/lib/x86_64-linux-gnu/pgm-5.1/include 和命令 pkg-config --libs openpgm-5.1 returns -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/

然后 Netpbm 安装在 Ubuntu 上。

错误2.pkg-config --cflags返回的include路径错误

默认包含路径为/usr/local/netpbm/include,库路径为/usr/local/netpbm/lib.

错误3.pkg-config --libs返回的链接选项-lpgm错误

正确的链接选项应该是-lnetpbm

按照正确的方法,我可以在Netbeans中成功编译项目(忘记命令行make)。