简体   繁体   中英

Troubles when compiling phash program

here is some (probably) very simple problem: I'm trying to use the perceptual hashing library pHash with Ubuntu 11.10. I already had ffmpeg installed, by the way this is what I've done:

sudo apt-get install libphash0
sudo apt-get install libphash0-dev

Then tried to compile this program:

#include <iostream>

#include <pHash.h>

using namespace std;

int main()
{
    ulong64 myhash=0;

    ph_dct_imagehash("test.jpg", myhash);
    cout<<myhash<<endl;
}

When compiling, it just prints out:

undefined reference to `ph_dct_imagehash'

Any suggestion? What should I do? Thanks in advance!

Matteo Monti

You didn't link to the library. Headers contain definition of library contents. Actual implementation is in library itself. You may link to it either statically or dynamically.

If you're using make, add your library path to makefile and recompile:

LIBS = -L/path/to/your/lib -lyourlib

If library is installed in system, it's probably in one of known paths. (/usr/lib/ or ...). So try adding:

LIBS = -lyourlib

Note: make system interprets -lname as <path>/libname.so . Not always true, but its like almost that.

You certainly forgot to link the pHash library, so the linker cannot find this function.

Try adding -l pHash to your GCC command line (or update your makefile). If it doesn't work, maybe you'll also need to specify the library path (the location of the *.a file) using -L "/usr/lib/"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM