`pkg-config --libs libraryname`
can be used if pkg-config and an appropriate config-file exists.
Just place it including the backticks in your projects build options, tab "Linker settings -> Other linker options".
`pkg-config --cflags libraryname`
can be used for includes and compile-flags in "Compiler settings -> Other options".
The backticks work on windows also (only in C::B).
You can, of course, call any other external program or script also and the call within the backticks will be replaced by the output.
Thanks, Jens! I tried what you said and it works!
I still feel very hard to get declarations of functions of the libraries I am using. I cannot get the declarations by right-clicking and choosing to jump to their declarations in the header files or by placing the mouse on their name to get a hint. However in Visual C++, I can get declarations of the functions in either way. I think I must miss something in CB. Please help if you have any idea. I am using svn5432 by the way. Thanks a lot!
some other updates:
While "gcc `pkg-config --cflags --libs opencv` `pkg-config --cflags --libs gtk+-2.0` -o my-prgm my-prgm.c" works fine, building my program with same settings in CB can give erros like these:
1. /usr/lib/libgtk.a and /usr/lib/libgdk.a are not found. gtk+-2.0 is installed on my system, but the missing library files are provided by a lower gtk version gtk-1.2 and the problem can be fixed by installing gtk-1.2. Is this because codeblocks is based on gtk-1.2 or something?
2.
/usr/lib/libX11.a(CrGlCur.o)||In function `open_library':|
||warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking|
/usr/lib/libdl.a(dlopen.o)||In function `dlopen':|
(.text+0x1b)||undefined reference to `__dlopen'|
/usr/lib/libdl.a(dlsym.o)||In function `dlsym':|
(.text+0x1b)||undefined reference to `__dlsym'|
||=== Build finished: 2 errors, 1 warnings ===|
I fix it by adding libdl.a to linking. Is it because codeblocks is based on libdl or some other reason?