Libconfig is not a static link. how to compile into a program

I download the archive using libconfig, but I don't want to install it on the system. Do I want to compile it as a static library and link it to the program reference, or link it directly to my program at compile time of the program ?

Any ideas how to do this using a Makefile? (FreeBSD (UNIX), GCC) or suggest other unix configuration libraries that support compilation in the program.

+3


source to share


1 answer


On a linux system, untar then configure and run:

> ls
libconfig-1.4.8.tar.gz
> tar -zxvf libconfig-1.4.8.tar.gz
> cd libconfig-1.4.8
> ./configure prefix=/somewhere/in/your/homedir/doesnotmatter
> make
> ls -al lib/.libs
libconfig.a
libconfig++.a
...
other versions of lib

      

Then link your application to the static library .a

.

gcc -I/dir/with/libconfigheader -o yourapp main.cpp libconfig.a

      



If you don't make install

, it won't get installed , the libraries will be in the output directory, you can copy them where you need them.

Hope this helps.

NOTE I didn't try to use the library, I just downloaded and compiled it ...

+8


source







All Articles