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

标签 linux makefile include-path pkg-config

我正在尝试在此网页中制作 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 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 编译过程的人可以帮助我解决这个问题。非常感谢。

最佳答案

我自己解决了这个问题。

原问题中提到的 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/

相关文章:

linux - Swift Linux 生成随机 bool

linux - 使用 Rsync 过滤器包含/排除文件

makefile - 尝试不同方法来制作目标的标准 makefile 习语是什么

c++ - 如何确保错误代码不会构建在 CI 流程中?

c++ - 如何在大约 v2.8.8 的 cmake 中轻松包含来自库依赖项的 header

c++ - 使用原生 CUDA 支持 CMake 在 C++ 目标中获取 CUDA 包含目录?

linux - Ubuntu 12.04 : ld cannot find library

Linux:使用Python捕获发送到ULOG的数据包? (带宽监控项目)

c++ - CodeLite:makefile 中的相对路径

c++ - 为使用 conda 安装的仅 header 库设置包含路径