Search code examples
c++dllmakefilestatic-librariesmingw32

How do you configure a makefile project that builds against a static library to build against a dynamic library instead?


I have a C++ project that is required to be built with a static version of Qt. However, QtWebKit will not successfully build statically, though it does build into a dll just fine.

My question is this: how do I tell a Makefile to use dlls instead of static libraries? This seems like it should be a trivial task, though I don't have enough experience with Makefiles to know how to do this. Thanks in advance for any assistance on this.


Solution

  • In linux using GNU Make environment, the process of linking with static library is

    gcc obj1.o obj2.o staticlib.a -o outfile //not considering include path for static library

    and, linking with a dynamic library is

    gcc obj1.c obj2.c -o outfile -labc //dynamic library is libabc.so, not considering the path

    From the man page of gcc we can see that,

    • -l Search the library named library when linking. The directories searched include several standard system directories plus any that you specify with -L
    • -L Add directory to the list of directories to be searched for -l.

    Please update your makefile accordingly.

    Cheers!!