Wednesday, July 15, 2009

MinGW: Building Static Pkg-Config

Since compiling Glib requires pkg-config and pkg-config depends on glib, there's an interdependency problem between glib and pkg-config. This poses a dilemma as one has to wonder which he should compile first, glib or pkg-config. I believe there's a need for a static pkg-config build in this situation.

So I started to build pkg-config statically. This means that the produced pkg-config won't have dependencies on libglib-2.0-0.dll, libintl-8.dll, libiconv-2.dll and libcharset-1.dll. The single pkg-config.exe will be self-sufficient. Basically, to produce static pkg-config, one should also build libiconv, gettext and glib statically, then build pkg-config, as shown below:




  1. First, compile libiconv statically

    ./configure --prefix=/mingw --disable-shared
    make
    make install

  2. Then, build gettext statically

    ./configure --prefix=/mingw --enable-threads=win32 --enable-relocatable --disable-shared
    make
    make install

  3. Temporarily, install Cygwin's pkg-config only to build static glib, as shown in this post.
  4. Build Glib statically

    ./configure --prefix=/mingw --with-threads=win32 --with-pcre=internal --disable-shared --disable-debug
    make
    make install

  5. At last, compile static Pkg-config

    ./configure --prefix=/mingw 
    make
    make install

    If you get compile errors about undefined references to libiconv, extract objects from libiconv.a and add them to libintl.a. Be warned this is unorthodox hack. Suggestions are welcome.


    cd /mingw/lib
    ar x libiconv.a
    mv -iv relocatable.o iconv_relocatable.o
    ar r libintl.a iconv.o iconv_relocatable.o libiconv.res.o

    Then, resume make. You'll get static pkg-config.exe that has no special dependency.





Here's the product of this tutorial: pkg-config.exe (static build).

No comments:

Post a Comment

About This Blog

KBlog logo This blog is about current events and issues concerning general population. Thanks for visiting the blog and posting your comments.

© Contents by KBlog

© Blogger template by Emporium Digital 2008

Followers

Total Pageviews

icon
Powered By Blogger