Search code examples
c++wxwidgetsubuntu-18.04

wxWidgets installed with incorrect header path


I just installed wxWidgets on Ubuntu 18.04 for C++ using the instructions from the following URL: https://www.binarytides.com/install-wxwidgets-ubuntu/

The installation was successful, but instead of calling the header file as #include <wx/wx.h> I have to call for it as #include <wx-3.1/wx/wx.h> which is leading to issues inside additional header files that also call for <wx/wx.h>

Is there any way I can remove the 'wx-3.1' without reinstalling or will I have to go in the header files and add this prefix each time this is called?


Solution

  • The headers are installed correctly, you're just not using the correct path to include them. You must use wx-config to get the flags for compiling and linking your programs, e.g. your compile command should look like

    g++ -c `wx-config --cxxflags` foo.cpp 
    

    and your link command should look like

    g++ -o foo foo.o `wx-config --libs`
    

    If you do it like this, everything should work just as you expect.

    P.S. This has nothing to do with your question, but I wish I knew why people decide following instructions on some random 4.5 year old blog post instead of the official build instructions in the manual (or docs/gtk/install.md for Real Programmers who don't read the manuals). This post at least looks correct (after a brief look), but this is not always the case.