Kietz
Kietz

Reputation: 1406

using precompiled library packages

I figured the following out the hard way, because I didn't know what resource to look at. What should I have read?

I used aptitude to install the c++ library package libexample5.3 and libexample5.3-dev

To link libexample into test.cpp, compile with:

g++ -o test test.cpp -lexample

But first all the entities linked to must be declared:

#include <example.h> //contains declarations of everything provided by libexample
int main() {
    return example::CONSTANT_2;
}

Upvotes: 4

Views: 2841

Answers (1)

Matteo Italia
Matteo Italia

Reputation: 126837

For the libexample/libexample-dev stuff, the position of shared libraries and the like see the Debian policy manual; for the working of the -l flag, see the g++ manpage; for the fact that you have to #include some header to use a library, that's usual practice, but it's usually documented anyway in the library documentation.

Upvotes: 1

Related Questions