Possible wxWidgets change Topic is solved

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
Post Reply
Bryan Kelly
Earned some good credits
Earned some good credits
Posts: 117
Joined: Wed Apr 27, 2022 10:47 pm

Possible wxWidgets change

Post by Bryan Kelly »

The zip that doublemax provided in this thread:
viewtopic.php?p=213642&sid=c987f8905871 ... 331a9b51c9
And the file named:
minimal_anywhere_test_v2.zip
Provided the results I needed.

Thank you profusely for that solution.

But, upon creating a project by copying and name changing, the build process produces this error at the bottom
1>C:\WXWIDGETS\3.2.0\include\wx\platform.h(159,10): fatal error C1083: Cannot open include file: 'wx/setup.h': No such file or directory
Examine file platform.h and look for setup.h to find this code phrase:

Code: Select all

/*
   Include wx/setup.h for the Unix platform defines generated by configure and
   the library compilation options

   Note that it must be included before defining hardware symbols below as they
   could be already defined by configure but it must be included after defining
   the compiler macros above as msvc/wx/setup.h relies on them under Windows.
 */
#include "wx/setup.h"
Now note that setup.h does not exist in directory wx. The full path for that directory on this machine is: C:\WXWIDGETS\3.2.0\include\wx
Within directory wx do a search for setup.h. There are multiple instances of this file, each in its own sub-directory. Apparently there is one for each of the different models/environment for which wxWidgets is configured for. The item that appears appropriate for Visual studio is:

Code: Select all

"C:\WXWIDGETS\3.2.0\include\wx\msw\setup.h"
Here are a few thoughts:
1. The statement #include “wx/setup.h” is incomplete.
2. A copy of setup.h must be in directory wx.
Bear in mind that those sub directories exist for a reason so referencing a setup.h within a subdirectory of the wx directory is probably not the best choice.
Then again, platform.h is not specific to Visual Studio. That means that a simple change to the #include statement in there can lead to a problem.
A better solution might be to shroud that #include statement with something like:

Code: Select all

#ifdef __ANDROID __
   #include “wx/android/setup.h”
   #define MODEL_FOUND
#endif
#ifdef __WINDOWS __
   #include “wx/msw/setup.h”
   #define MODEL_FOUND
#endif
…
// the below forces an easy to find error.
#ifndef MODEL_FOUND
   #include “model_not_found.h”
#end if
My searches did not find a macro to the effect:

Code: Select all

#elifndef __SOMETHING__
Resulting in a more complex set of macros.
To my specific setup, file platform.h was changed as follows:

Code: Select all

// #include "wx/setup.h" // BK this include is not correct.  Made temporary change
#ifdef __WINDOWS__
   #include "wx/msw/setup.h"
#else
   #include "wx/setup.h"
#endif
The else is to provide an error if the define of __WINDOWS__ did not work out. It does work for me, but maybe not in the general sense.

So: Do I have a bad setup? Or is a wxWidgets change needed? And if a change is needed, what is the complete change that includes all the models?
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Possible wxWidgets change

Post by doublemax »

[...]
Provided the results I needed.

Thank you profusely for that solution.

But, upon creating a project by copying and name changing, the build process produces this error at the bottom
So did it work or not?
Here are a few thoughts:
1. The statement #include “wx/setup.h” is incomplete.
2. A copy of setup.h must be in directory wx.
No. You don't have to make any such changes. If something doesn't work, it's a problem with your compiler setup.

There is one "master" copy of setup.h in a platform-specific directory inside the wxWidgets source tree. E.g. for Windows this is in <wxdir>/include/wx/msw/setup.h

If you build the wxWidgets libraries, this file will be copied to a "build specific" directory. E.g. <wxdir>/lib/vc_lib/mswu/setup.h (for Visual C++, 32bit, static linking, Unicode, non-debug).

When you compile your own application using that specific configuration, you need to set that directory as the first(!) include directory. That will be the directory setup.h is included from. The other header files will be included from <wxdir>/include/

For Visual C++ alone there is another option, which is to use <wxdir>/include/msvc/ as include path, which has the advantage that this will automatically link the correct libraries to your application. However, the sample project i provided does not use this feature, it uses the include method that every other compiler uses.
Use the source, Luke!
Bryan Kelly
Earned some good credits
Earned some good credits
Posts: 117
Joined: Wed Apr 27, 2022 10:47 pm

Re: Possible wxWidgets change

Post by Bryan Kelly »

The file is not in the required location. Its just not there.
I have downloaded the source code and have done the build.
I am not recognizing anything that tells me how to get it there.
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Possible wxWidgets change

Post by doublemax »

I'll explain it again:

When building a wxWidgets app, you'll need at least two include base directories:

1. <wxdir>/lib/<SOMETHING_CONFIGURATION_SPECIFIC>
this is where setup.h will be included from (and nothing else)

E.g on my system, for the configuration: <32bit, static linking, unicode, debug>, it is:
F:\DEV\wxWidgets\lib\vc_lib\mswud
Depending on the compiler and configuration, this will be a different path. This directory is not in the wx source files. It and its content will only be created when building this specific configuration of the wxWIdgets libraries. And when you open it, you'll see there is a folder "wx", and in it the file "setup.h"

2. <wxdir>/include/
this is from where the header files for all controls etc. are included

The order is important. The configuration-specific include directory must be first in the list.
Use the source, Luke!
Bryan Kelly
Earned some good credits
Earned some good credits
Posts: 117
Joined: Wed Apr 27, 2022 10:47 pm

Re: Possible wxWidgets change

Post by Bryan Kelly »

Where do the includes belong? Here?

Code: Select all

Project -> Properties -> VC++ Directories -> Include Directories.
But this leaves the question unaddressed. Platform.h contains the line:

Code: Select all

#include "wx/setup.h"
When that wx directory is found, here:

Code: Select all

C:\WXWIDGETS\3.2.0\include\wx
There is no file named setup.h in that directory.
I don’t understand how adding anything to that section of properties will cause a new setup.h file to be created.
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Possible wxWidgets change

Post by doublemax »

BTW: Did the sample project i provided work, or not? And if it did, why don't you just use it?
Bryan Kelly wrote: Thu Aug 11, 2022 12:28 am But this leaves the question unaddressed. Platform.h contains the line:

Code: Select all

#include "wx/setup.h"
When that wx directory is found, here:

Code: Select all

C:\WXWIDGETS\3.2.0\include\wx
There is no file named setup.h in that directory.
"wx/setup.h does not describe an absolute path. The file can be in any path relative to any of the include directories given. And in this case it will be found in C:\WXWIDGETS\lib\vc_lib\mswud
(like mentioned before, this is an example, the path can look different)
I don’t understand how adding anything to that section of properties will cause a new setup.h file to be created.
It doesn't. That functionality is *only* in the build process for the wxWidgets libraries. Not in your project.

And if you want to see it:
Open one of the VS solution files in Visual Studio.

In the "_custom_build" project, under "Setup Header", select "setup.h"
Right click -> Properties -> Configuration Properties -> Custom Build Tool -> General

There you'll find the command to copy that "master" copy of setup.h to its destination.
Use the source, Luke!
Bryan Kelly
Earned some good credits
Earned some good credits
Posts: 117
Joined: Wed Apr 27, 2022 10:47 pm

Re: Possible wxWidgets change

Post by Bryan Kelly »

This is really getting to me. I am using your solution. downloaded and unzipped the file. Left everything the same for first attempt. Then when I figured out the change, made the noted change, then renamed stuff and started my project. Same code just different names. I did get that right.

Just now, just to verify, I removed the fix, err, change, just to be certain of what I am trying to do. Both in your original version and in my personalized version. Both are working now without my change. And I do not understand.
I am happy it is working, but very concerned that I had a problem and now the problem is gone. I didn't add any wx stuff in the Properties pages.

I don't know what to do now, other than this:
Thanks to you, I now have a starter project for wxWidgets.
Thank you for your time, and thank you for the huge amount of patience you have shown.
Bryan Kelly
Earned some good credits
Earned some good credits
Posts: 117
Joined: Wed Apr 27, 2022 10:47 pm

Re: Possible wxWidgets change

Post by Bryan Kelly »

I continue to be puzzled about how this solution is successful.
Regarding the original post, I went back to directory:

Code: Select all

C:\WXWIDGETS\3.2.0\include\wx
and setup.h is not present.
File platform.h still has the original line:

Code: Select all

#include "wx/setup.h"
How can VS build successfully when there is no file that has that phrase in its path?
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Possible wxWidgets change

Post by doublemax »

I've explained it twice already and i don't know how else to explain it...
Regarding the original post, I went back to directory:

Code: Select all

C:\WXWIDGETS\3.2.0\include\wx
and setup.h is not present.
This directory is not the one where setup.h is included from. So it's correct that setup.h is not there.


See that there are two different paths for include files given.
"setup.h" will be included from the first one.
When the compiler "sees" a #include directive, it will check all include paths one by one, and will use the first file that matches.
vs2022_win11_minimal_anywhere.png
vs2022_win11_minimal_anywhere.png (7.87 KiB) Viewed 6803 times
Use the source, Luke!
Bryan Kelly
Earned some good credits
Earned some good credits
Posts: 117
Joined: Wed Apr 27, 2022 10:47 pm

Re: Possible wxWidgets change

Post by Bryan Kelly »

I looked again and now see what you are saying. I don't know how I missed it.
Thank you again for your patience.
Post Reply