Search code examples
c++wxwidgets

wxWidgets lots of undefined references


I downloaded the source to the latest wx and managed to compile it without any issues.

Configured with:

../configure --enable-optimise --enable-stl --enable-unicode --enable-threads --enable-static --disable-shared --prefix=/usr/local

When I try to compile this example with:

g++-4.8 `wx-config --libs` `wx-config --cxxflags` test.cpp 

I get alot of undefined refferences ( full list here )

How can I make this work?


Solution

  • When using static libraries, as you do (because of --disable-shared in configure command line), the libraries must come after the object file that references them (this is a general rule with all Unix-ish linkers and definitely with GNU ld). So the correct command line would be

    g++-4.8 `wx-config --cxxflags` test.cpp `wx-config --libs`
    

    or, just to keep it short, and because it does not matter where do the compilation flags appear:

    g++-4.8 test.cpp `wx-config --cxxflags --libs`