c++visual-studiowxwidgetswxformbuilder

How to include wx in my c++ code (MSVS 2019)


I want to include the wx library in my c++ program but following the given default instruction don't include the library in Visual Studio 2019

I tried (quoting from the instruction install.md):

  1. Open a "Visual Studio Command Prompt"

  2. Change directory to \%WXWIN\%\build\msw and type

    > nmake /f makefile.vc
    

Also i tried to include the file wxwidgets.props as explained in the given instruction

If i try to do

#include <wx/frame.h>

is marked as mistake ("impossible to open "wx/frame.h" of origin file)

Note: for the creation of the GUI I'm also using wxFormBuilder


Solution

  • After some time wondering around forum, I've found a video on Youtube explaining how to include wx in your Visual Studio project, so i decided to post the answer to my question helping how will need this help in the future like i needed.

    1. First of all you need to open in the Wx Directory and go to wxWidgets-X.X.X\build\msw and open with Visual Studio wx_vc15.sln (or more recent if available)
    2. Compiling the solution in Debug, DebugDLL, Relase and RelaseDLL.
    3. Now open your project (new or old) and open the Project menu and tap Project propriety
    4. Select configuration All configuration, go to section C/C++ and in Additional Include directorys add \wxWidgets-X.X.X\include
    5. Next go under Preprocessor and add in Processor definition the string WXUSINGDLL
    6. Go under Linker and on Additional library Directory add \wxWidgets-X.X.X\lib\vc_dll
    7. Change configuration to debug and under C\C++ add another additional include directory that is wxWidgets-X.X.X\lib\vc_dll\mswud
    8. Finally, as step 7, change to relase and add wxWidgets-X.X.X\lib\vc_dll\mswu

    This will include the wx library in your code

    Here the link for the video https://www.youtube.com/watch?v=EI2taYkErRg if you need more detail or if you need visually the explaination.

    NOTE: in the install.md is missing the part of including the library in the project in this way, it mention only to compile the Debug version not well explaining why or what to do next.