Say I find a very nice open source library in the internet and now I want to use it for my own project.
I download it, possibly compile it and get the header files & the static/dynamic library.
So I start writing my own source files and of course when I want to use functionality from this external library I include the right headers of it into my source files.
Now I compile my source file, make sure the include paths and linker options for this external library are set correctly.
And I get heaps of errors, all coming from the external headers.
Turns out they require some compiler flags.
How do I find out the minimal compiler flags that I have to set (to be able to compile headers from an external library)?
What I’ve thought about it so far:
- Look them up in the building script of the source (can be quite hard, since there are many places where they can be defined and they may not be the minimal flags, since they may be required for all headers together, but not for specific ones I use)
- Google every error message and hopefully that’ll give the answer (can be hard with a lot of error messages and google might not know the answer, or I might not know the right keywords to find the answer)
- Maybe somehow ‘include’ the build script of the external library into my own project (could be very hard, since I might want to use a different build system and I’d probably have to fully understand the build system myself, which could be hard for bigger libraries)
Any well behaved open source library ships with instructions on how to use their development files. On GNU/Linux systems, it’s usual to have pkg-config files (*.pc) installed together to development headers and libraries, in which case
pkg-config --cflags library-namewill tell about required compilation options.Where
pkg-configcan be used, it’s just a matter of telling the build-system which components you’d like to import. E.g. on autotools.And then make use of
DEPS_CFLAGSandDEPS_LIBSvariables on .am files.E.g. on a shell command-line:
Anyway, it’d be more productive if you could post specific info about the library used and which are the errors being generated.