libharu, how to compile (undefined reference to)
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: libharu, how to compile (undefined reference to)

  1. #1

    libharu, how to compile (undefined reference to)

    g++ /usr/local/lib/libhpdf.a /usr/local/lib/libhpdf.so pdf.cpp

    gives me:

    pdf.cpp.text+0xb7): undefined reference to `HPDF_New'
    pdf.cpp.text+0xf9): undefined reference to `HPDF_Free'
    pdf.cpp.text+0x10f): undefined reference to `HPDF_AddPage'
    .....
    ------------------------------------------------------------------------------------------
    ok, eventually i compiled it with "gcc pdf.cpp -lhpdf -lpng -lz -lm"

    but now it says:
    ./a.out: error while loading shared libraries: libhpdf-2.2.1.so: cannot open shared object file: No such file or directory

    even after i copied this file into current dir((
    Last edited by Igor Yalovecky; December 2nd, 2011 at 04:20 AM.

  2. #2
    Join Date
    Apr 2009
    Posts
    598

    Re: libharu, how to compile (undefined reference to)

    Try, by first compiling your cpp file to produce an object file, then by linking you object file with the object files included in the libraries:

    Code:
    g++ -c pdf.cpp -o pdf.o
    
    g++ pdf.o -L"/usr/local/lib" -lhpdf -o "pdf.exe"
    Edit:
    Glad you find the right command line.

    "cannot open shared object file: No such file or directory" means you have to copy libhpdf-2.2.1.so in a directory that is listed in the PATH environment variable.
    Last edited by olivthill2; December 2nd, 2011 at 04:26 AM.

  3. #3

    Re: libharu, how to compile (undefined reference to)

    Quote Originally Posted by olivthill2 View Post
    Try, by first compiling your cpp file to produce an object file, then by linking you object file with the object files included in the libraries:

    Code:
    g++ -c pdf.cpp -o pdf.o
    
    g++ pdf.o -L"/usr/local/lib" -lhpdf -o "pdf.exe"
    Edit:
    Glad you find the right command line.

    "cannot open shared object file: No such file or directory" means you have to copy libhpdf-2.2.1.so in a directory that is listed in the PATH environment variable.
    Great thanks! I found next command to ran it:
    LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib ; export LD_LIBRARY_PATH

    but what is -lhpdf. is it some system name for library or some kind of shorcut?

  4. #4
    Join Date
    Apr 2009
    Posts
    598

    Re: libharu, how to compile (undefined reference to)

    what is -lhpdf?

    -l means, you use a library

    hpdf is the name of the library where its extension (characters after the ".") and its first three characters "lib" have been removed, in order to gain some valuable space on the command which used to be quite short in prehistorical times.

Posting Permissions

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


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center