c++unixgccconfiglibconfig

libconfig not static linkage. how to compile into program


I download the archive with libconfig, but I do not wont to install it into the system. I want to compile it as static library and link it from program girectory or directly link it into my program on the program compile time?

Any ideas how to do this with Makefile? (FreeBSD(UNIX), GCC) or suggest other unix config libraries that support compilation into the program.


Solution

  • On linux system untar then configure and make:

    > 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 against the static .a library.

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

    If you don't do make install it will not get installed, the libraries will be in the output directory, you can copy them where you need them.

    I hope this helps.

    NOTE I haven't tried to use the library, I just downloaded and compiled it ...