-
December 2nd, 2011, 05:07 AM
#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 05:20 AM.
-
December 2nd, 2011, 05:22 AM
#2
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 05:26 AM.
-
December 2nd, 2011, 05:47 AM
#3
Re: libharu, how to compile (undefined reference to)
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?
-
December 2nd, 2011, 06:12 AM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|