Question

A quick Google search of this issue shows it's common, I just can't for the life of me figure out the solution in my case.

I have a straight forward install of wxWidgets 2.8.8 for Windows straight from the wxWidgets website.

Whenever I try to compile anything (such as the sample app described in "First Programs for wxWidgets" - http://zetcode.com/tutorials/wxwidgetstutorial/firstprograms/ ) I get:

wx/setup.h: No such file or directory

I've included both C:\wxWidgets-2.8.8\include and C:\wxWidgets-2.8.8\include\wx in my compiler search list.

It should be simple - but it's not! :(

The same thing happens if I try to use an IDE integrated with wxWidgets (such as Code::Blocks) - and this, I would have thought, would have just worked out the box...

So, some help please... Why is setup.h not found?

Was it helpful?

Solution

wxWidgets is not built into useable libraries when you "install" the wxMSW installer. This is because there are so many configurable elements, which is precisely what the setup.h you refer to is for.

If you just want to build it with default options as quickly as possible and move on, here is how:

  1. Start the "Visual Studio Command Prompt." You'll find this in the start menu under "Microsoft Visual Studio -> Visual Studio Tools".

  2. Change to folder: [WXWIN root]\build\msw

  3. Build default debug configuration: nmake -f makefile.vc BUILD=debug

  4. Build default release configuration: nmake -f makefile.vc BUILD=release

  5. Make sure the DLLs are in your PATH. They'll be found in [WXWIN root]\lib\vc_dll

  6. Under the DLL folder mentioned above, you will find subfolders for each build variant (The instructions above made two, debug and release.) In each variant folder you'll find a 'wx' folder containing a 'setup.h" file. You'll see that the setup.h files are actually different for each build variant. These are the folders you need to add to your project build configuration include path, one per build variant. So, for example, you'd add [WXWIN root]\lib\vc_dll\mswud to the include path for your debug build, [WXWIN root]\lib\vc_dll\mswu for your release build.

  7. It is possible to build lots of other variant combinations: static libs, monolithic single library, non-Unicode, etc. See [WXWIN root]\docs\msw\install.txt for much more extensive instructions.

OTHER TIPS

When building wxWidgets, it dynamically creates a setup.h file for each build configuration that is built. The generated setup.h files are stored in folders below the lib folder, for instance (Visual Studio on Windows):

c:\wxWidgets-2.9.2\lib\vc_lib\mswu

To successfully build a project based on wxWidgets, each build configuration in the project must be set up with its own Additional Include Directory that points to the corresponding wxWidgets build folder under lib, such as the one listed above.

In addition, an Additional Include Directory that is common for all build configurations in the project must be set to point to wxWidget's main include folder. This folder is typically set up in a user property sheet that can be used in any project. E.g.:

c:\wxWidgets-2.9.2\include

For linking, an Additional Library Directory common for all build configurations is set up to point to the wxWidgets lib folder. E.g.:

c:\wxWidgets-2.9.2\lib\vc_lib

And then, specific to each build configuration, Additional Dependency entries are set up to include libraries of the corresponding wxWidgets libraries. E.g., for a Unicode, Debug build (u = Unicode, d = Debug):

wxbase29ud.lib

Then, to use wxWidgets in your project, start out by including the generated setup.h file:

#include "wx/setup.h"

And then include headers for specific wxWidgets functionality. E.g.:

#include <wx/slider.h>
#include <wx/image.h>
#include <wx/control.h>

You probably need to build wxWidgets. There is a post-build step in the wxWidgets build process that copies the appropriate setup.h into C:\wxWidgets_install_dir\include\wx.

For anything to work, you first have to build the core libraries (wx_vc#.sln files). Then you can work with the remainder stuff.

Remember you need CppUnit for testcases to compile.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top