Skip to content
Advertisement

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

I am trying to make the PCA-SIFT code (pcasift-0.91nd.tar.gz) in this webpage: http://www.cs.cmu.edu/~yke/pcasift/. After running ./configure which is OK, the make command report that the C compiler can not find header pgm.h:

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

There is a webpage in internet which discussed this issue: http://ubuntuforums.org/showthread.php?t=1918422. A solution was stated at the end:

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.

, but I cannot understand it. Specifically, what does “add pkg-config --cflags openpgm-5.1 at the end of your compilation command” mean? What should I do, to add pkg-config --cflags openpgm-5.1 literally or the results this command returns in terminal? And add to what file? The Makefile is generated by ./configure. Should I add to Makefile or ./configure? I have successfully install libpgm-dev and they are really in /usr/include/pgm-5.1. The command pkg-config --cflags openpgm-5.1 returns -I/usr/include/pgm-5.1 -I/usr/lib/x86_64-linux-gnu/pgm-5.1/include and command pkg-config --libs openpgm-5.1 returns -lpgm -lpthread -lm.

Since that thread was closed, I have to ask here. Hoping someone familiar with Linux compiling process could help me with this issue. Thanks a lot.

Advertisement

Answer

I solved the problem myself.

Everything in the ubuntuforums.org webpage mentioned in the original question is wrong; that’s why I met with so many problems.

Wrong 1: It’s wrong to install libpgm-dev using sudo apt-get install libpgm-dev. We should download Netpbm, and run the following command after uncompression:

./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/

Then Netpbm is installed on Ubuntu.

Wrong 2. The include path returned by pkg-config --cflags is wrong

By default, The include path shold be /usr/local/netpbm/include and the lib path is /usr/local/netpbm/lib.

Wrong 3. The linking option -lpgm returned by pkg-config --libs is wrong

The correct linking option should be -lnetpbm.

Following the right way, I can successfully compile the project in Netbeans (forget about command line make).

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement