Results 1 to 3 of 3

Thread: Troubles when compiling pHash

  1. #1
    Join Date
    Jun 2012
    Beans
    1

    Question Troubles when compiling pHash

    Hi all,
    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:

    Code:
    sudo apt-get install libphash0
    sudo apt-get install libphash0-dev
    Then tried to compile this program:

    Code:
    #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:
    Code:
    undefined reference to `ph_dct_imagehash'
    Any suggestion? What should I do?
    Thanks in advance!

    Matteo Monti

  2. #2
    Join Date
    Apr 2009
    Location
    Germany
    Beans
    2,134
    Distro
    Ubuntu Development Release

    Re: Troubles when compiling pHash

    libraries need to be behind objects needing them:
    Code:
    $ g++ file.c -lpHash

  3. #3
    Join Date
    Sep 2009
    Beans
    1,293

    Re: Troubles when compiling pHash

    Most likely you're linking libraries after objects, ie
    Code:
    #g++  -lpHash test.cpp  # Wrong!
    /tmp/cclknlvN.o: In function `main':
    test.cpp:(.text+0x1d): undefined reference to `ph_dct_imagehash'
    collect2: ld returned 1 exit status
    #g++ test.cpp  -lpHash # Right!
    For the reason why...
    http://www.gentoo.org/proj/en/qa/asneeded.xml
    Note, --as-needed is default these days, perhaps a well written explanation should go down as a sticky

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •