norman's blog

Notes of an amnesiac.
Never stop thinking.
Find an aesthetic description.

Thursday, May 14, 2009

Tools accompany with Make

CTAGS

ctags parses source code and produces a sort of index mapping the names of significant entities (e.g. functions, classes, variables) to the location where that entity is defined. This index is used by editors like vi and emacsen to allow moving to the definition of a user-specified entity.
install:
apt-get install exuberant-ctags

PKG-CONFIG

The pkg-config program is used to retrieve information about installed libraries in the system. It is typically used to compile and link against one or more libraries.
.pc file
When a library is installed (say from an RPM, deb or other binary packaging system), a .pc file should be included and placed into a directory with other .pc files (the exact directory is dependent upon your system and reflected in PKG_CONFIG_PATH). This file has several entries. These entries typically contain the libraries that the other programs using the package needs to compile as well as the location of header files, version information and a description.If one installs from source, often there will be no .pc file generated, and one may need to be manually written to reflect the install.
Here is an example .pc file for libpng:
prefix=/usr/local
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${exec_prefix}/include
 
Name: libpng12 
Description: Loads and saves PNG files
Version: 1.2.8
Libs: -L${libdir} -lpng12 -lz
Cflags: -I${includedir}/libpng12
This file tells us that libraries can be found in /usr/local/lib and headers in /usr/local/include, that the library name is libpng12 and the version is 1.2.8. It also provides the linker flags that are needed to compile code depending upon libpng.
Usage
Here is an example of usage of pkg-config while compiling some program using libpng:
gcc -o test test.c $(pkg-config --libs --cflags libpng)
The pkg-config will search paths stored in PKG_CONFIG_PATH to find libpng.pc, then pass information to gcc.

Labels:

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home