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((
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.
Re: libharu, how to compile (undefined reference to)
Quote:
Originally Posted by
olivthill2
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?
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.