| re: C++/C-library linking (pslib)
"Thomas Ruschival" <t.ruschival@vivid-md.de> wrote...[color=blue]
> as far as I know I can link all C libraries in C++ as well. but I can't
> get it done with pslib. pslib is a library to create Postscript documents.
> The exactly same code compiles and links with C and it doesn't when I
> use C++.[/color]
The two languages are different enough to make it generally possible.
[color=blue]
> This is my linking command:
> gcc -o test -L/usr/lib/ -lps -lstdc++ test.cpp
>
> and in /usr/lib is definitely the file
> /usr/lib/libps.so -> libps.so.0.2.4
>
> it all works fine when I compile my file as test.c as C
> code. but with test.cpp I get these errors:
>
> /tmp/ccSuItDe.o(.text+0x11): In function `main':
> : undefined reference to `PS_boot()'
> /tmp/ccSuItDe.o(.text+0x16): In function `main':
> : undefined reference to `PS_new()'
> [bla bla bla and so on......................]
> collect2: ld returned 1 exit status
>
> this is the stupid little piece of code I wrote after the
> bigger project didn't compile:
>
> #include <libps/pslib.h>
> main(int argc, char *argv[]) {
> PSDoc* sheet;
> PS_boot();
> sheet = PS_new();
> PS_open_file(sheet,"test.ps");
> PS_set_info(sheet,"Title","HelloWorld");
> PS_begin_page(sheet,841.9,595.3);
> PS_end_page(sheet);
> PS_shutdown();
> };
>
> what do I do wrong. BTW, I have debian [sid] running.[/color]
First of all, the code is not valid C++ code. The 'main' has implicit
return type, which is not allowed in C++.
Second, since the contents of <libps/pslib.h> are not known, the use of
it within a C++ program is not necessarily guaranteed.
Third, you have a superfluous semicolon after the closing curly brace.
I strongly recommend asking in comp.os.linux.development.app, since the
compiler command-lines, and paths, and how 'ld' resolves symbols, is all
platform-specific.
V |