Hello world will not compile in Release mode

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.
Bryan Kelly
Earned some good credits
Earned some good credits
Posts: 117
Joined: Wed Apr 27, 2022 10:47 pm

Hello world will not compile in Release mode

Post by Bryan Kelly »

Windows 11, Visual Studio 2019
When in debug mode it will compile and debugger can step into it.
Change to Release mode and immediately the first line of code gets the squiggles.
Error message: ...Cannot open include file...

Code: Select all

#include <wx/wxprec.h>
Multiple additional lines of code are flagged.
Change back to Debug and they are immediately resolved.
Looks like a configuration or properties problem, but I have not detected an obvious error.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7477
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Hello world will not compile in Release mode

Post by ONEEYEMAN »

Hi,
But can you actually compile it? I.e. can you click "Build" and then "Build Project" and it will compile cleanly.

The next question - did you build wxWidgets in Release mode? Or you build Debug libraries only?
In order to check it - open the Windows Explorer, navigate to the wxWidgets\lib folder, open the appropriate configuration and see if you have only "*ud.dll"
or "*u.dll" as well.

Thank you.
Bryan Kelly
Earned some good credits
Earned some good credits
Posts: 117
Joined: Wed Apr 27, 2022 10:47 pm

Re: Hello world will not compile in Release mode

Post by Bryan Kelly »

As noted in the OP, yes, I can build it. I removed all the breakpoints, pressed F5, and it displayed the empty dialog Hello World. I added some text on the end of the title, built it, ran it, and the new text is displayed.
As soon as Debug is changed to Release, it can no longer find the include files. Here is the text from the Output panel in release mode.
Build started...
1>------ Build started: Project: wxwidget_01, Configuration: Release x64 ------
1>wxwidget_01.cpp
1>E:\CODE\WX\wxwidget_01\wxwidget_01.cpp(3,10): fatal error C1083: Cannot open include file: 'wx/wxprec.h': No such file or directory
1>Done building project "wxwidget_01.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Just to be complete, here is the contents of the "Output" panel after building in Debug mode.
Rebuild started...
1>------ Rebuild All started: Project: wxwidget_01, Configuration: Debug x64 ------
1>declare_event_table.cpp
1>wxwidget_01.cpp
1>Generating Code...
1>wxwidget_01.vcxproj -> E:\CODE\WX\wxwidget_01\x64\Debug\wxwidget_01.exe
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
And just to be sure, the only difference between the two builds is switching between Release and Debug.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7477
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Hello world will not compile in Release mode

Post by ONEEYEMAN »

Hi,
How did you build wxWidgets? Did you build the Debug version only or both Debug and Release?

It sounds like you did just the former and so you need to open wx_vcN.sln, go to "Build -> Batch Build...", select all project that belongs to the "Release" configuration and click "Build".

Then try to build the Release version of the "Hello World" again.

Or even better - try to build the minimal sample provided by the library. Open c:\wxWidgets\samples\minimial\wx_vcN.sln, change the configuration to "Release", build and run it.

Let us know how it goes.

Thank you.
Bryan Kelly
Earned some good credits
Earned some good credits
Posts: 117
Joined: Wed Apr 27, 2022 10:47 pm

Re: Hello world will not compile in Release mode

Post by Bryan Kelly »

I was not aware of building both at the same time or with batch. I have not explored VS nearly as much as I should have.
I visited that batch screen and set it up as shown.
batch_build_release.png
batch_build_release.png (26.76 KiB) Viewed 1272 times
The contents of the Output panel are below.
Build started...
------ Build started: Project: wxwidget_01, Configuration: Release Win32 ------
wxwidget_01.cpp
E:\CODE\WX\wxwidget_01\wxwidget_01.cpp(3,10): fatal error C1083: Cannot open include file: 'wx/wxprec.h': No such file or directory
Done building project "wxwidget_01.vcxproj" -- FAILED.
------ Build started: Project: wxwidget_01, Configuration: Release x64 ------
wxwidget_01.cpp
E:\CODE\WX\wxwidget_01\wxwidget_01.cpp(3,10): fatal error C1083: Cannot open include file: 'wx/wxprec.h': No such file or directory
Done building project "wxwidget_01.vcxproj" -- FAILED.
========== Build: 0 succeeded, 2 failed, 0 up-to-date, 0 skipped ==========
Edit
After doing that I tried a batch build for debug mode. It fails with this output
Build started...
------ Build started: Project: wxwidget_01, Configuration: Debug Win32 ------
wxwidget_01.cpp
E:\CODE\WX\wxwidget_01\wxwidget_01.cpp(3,10): fatal error C1083: Cannot open include file: 'wx/wxprec.h': No such file or directory
Done building project "wxwidget_01.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========
Interesting. Then go back to the main dialog and from the top select Build -> Rebuild solution to get these results.
Rebuild started...
1>------ Rebuild All started: Project: wxwidget_01, Configuration: Debug x64 ------
1>declare_event_table.cpp
1>wxwidget_01.cpp
1>Generating Code...
1>wxwidget_01.vcxproj -> E:\CODE\WX\wxwidget_01\x64\Debug\wxwidget_01.exe
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
Thank you for your time.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7477
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Hello world will not compile in Release mode

Post by ONEEYEMAN »

Hi,
My question meant to see if you did build the library (wxWidgets) in the release mode, not you application.

To check:

Open MSVC.
Go to File-> Open Project/Solution.
Navigate to the folder of c:\wxWidgets\build\msw\
and so use N=Open the wx_vcN.sln file (I have MSVC 2017 and so use N=15)
Go to Build -> Batch Build, click Select All, then Build.

After build finishes go back to your project and try building again.

Thank you.
Bryan Kelly
Earned some good credits
Earned some good credits
Posts: 117
Joined: Wed Apr 27, 2022 10:47 pm

Re: Hello world will not compile in Release mode

Post by Bryan Kelly »

My configuration is not as you expect.

Open MSVC.
.... did that, closed the hello world solution and that dialog
Go to File-> Open Project/Solution.
.... File -> Open -> Project / Solution
Navigate to the folder of c:\wxWidgets\build\msw\
.... Navigate to: C:\WXWIDGETS\3.1.7\build\msw
.... The directory is empty. I did not download source code.

and so use N=Open the wx_vcN.sln file (I have MSVC 2017 and so use N=15)
... "N = Open" I do not understand the meaning of that.

Go to Build -> Batch Build, click Select All, then Build.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7477
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Hello world will not compile in Release mode

Post by ONEEYEMAN »

Hi,
Get the source code and do your own build.
As you can see it is much easier.

Besides you will have access to a lot of sample code for the library.
You will be able to play with it (build/run/modify).
And you will have access to the source code in case you need to debug any problems.

Yes - it takes time to build, but you do it once and its a time wel spent.

Thank you.

BTW, you should get the 3.2.0 sources - it is latest stable release and so you will have access to a lot of latest fixes.

Thank you.
Bryan Kelly
Earned some good credits
Earned some good credits
Posts: 117
Joined: Wed Apr 27, 2022 10:47 pm

Re: Hello world will not compile in Release mode

Post by Bryan Kelly »

I tried that and appear to have introduced an error.
The wxwidget sources appears to all build fine.
Environment variable WXWIN was set to C:\WXWIDGETS\3.2.0 I had that set for 3.1.7, but this time I could not find WXWIN. So I set it and do not understand how it worked at all.

I recall setting a PATH environment variable, but don't see anything in PATH that references the wxWidgets directory.

Opened the wxwidgets hello world project and was rewarded with this information:
[6:32:32 PM] (wxwidget_01) Project does not reference Xamarin.Forms.
I don't know what it means.
With Release mode set, do a Build -> Rebuild Solution to get:
Rebuild started...
1>------ Rebuild All started: Project: wxwidget_01, Configuration: Debug x64 ------
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(39,5): warning MSB4211: The property "IntermediateOutputPath" is being set to a value for the first time, but it was already consumed at "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets (38,5)".
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.BuildSteps.Targets(30,5): warning MSB4211: The property "DebugType" is being set to a value for the first time, but it was already consumed at "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.BuildSteps.Targets (29,5)".
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(373,5): warning MSB4211: The property "CleanFile" is being set to a value for the first time, but it was already consumed at "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets (38,5)".
1>declare_event_table.cpp
1>wxwidget_01.cpp
1>Generating Code...
1>wxwidget_01.vcxproj -> E:\CODE\WX\wxwidget_01\x64\Debug\wxwidget_01.exe
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
It runs and pops the dialog but there are warnings in there.
Switch to Build -> Batch Build, and enable to two Release configurations.
Build started...
------ Build started: Project: wxwidget_01, Configuration: Release Win32 ------
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(39,5): warning MSB4211: The property "IntermediateOutputPath" is being set to a value for the first time, but it was already consumed at "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets (38,5)".
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.BuildSteps.Targets(30,5): warning MSB4211: The property "DebugType" is being set to a value for the first time, but it was already consumed at "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.BuildSteps.Targets (29,5)".
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(373,5): warning MSB4211: The property "CleanFile" is being set to a value for the first time, but it was already consumed at "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets (38,5)".
wxwidget_01.cpp
E:\CODE\WX\wxwidget_01\wxwidget_01.cpp(3,10): fatal error C1083: Cannot open include file: 'wx/wxprec.h': No such file or directory
Done building project "wxwidget_01.vcxproj" -- FAILED.
------ Build started: Project: wxwidget_01, Configuration: Release x64 ------
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(39,5): warning MSB4211: The property "IntermediateOutputPath" is being set to a value for the first time, but it was already consumed at "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets (38,5)".
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.BuildSteps.Targets(30,5): warning MSB4211: The property "DebugType" is being set to a value for the first time, but it was already consumed at "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.BuildSteps.Targets (29,5)".
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(373,5): warning MSB4211: The property "CleanFile" is being set to a value for the first time, but it was already consumed at "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets (38,5)".
wxwidget_01.cpp
E:\CODE\WX\wxwidget_01\wxwidget_01.cpp(3,10): fatal error C1083: Cannot open include file: 'wx/wxprec.h': No such file or directory
Done building project "wxwidget_01.vcxproj" -- FAILED.
========== Build: 0 succeeded, 2 failed, 0 up-to-date, 0 skipped ==========
The key item appears to be:
Cannot open include file: 'wx/wxprec.h': No such file or directory
Bryan Kelly
Earned some good credits
Earned some good credits
Posts: 117
Joined: Wed Apr 27, 2022 10:47 pm

Re: Hello world will not compile in Release mode

Post by Bryan Kelly »

Then I visited the samples directory, and went into Calendar. There was no solution there so I closed VS, double clicked file calendar_vc9.vproj. When Windows asked the program us use, selected VS. It performed a one way conversion, so I check the source code, looks ok. With the mode set to Debug, did the build to get:
Rebuild started...
1>------ Rebuild All started: Project: calendar, Configuration: Debug Win32 ------
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(39,5): warning MSB4211: The property "IntermediateOutputPath" is being set to a value for the first time, but it was already consumed at "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets (38,5)".
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.BuildSteps.Targets(30,5): warning MSB4211: The property "DebugType" is being set to a value for the first time, but it was already consumed at "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.BuildSteps.Targets (29,5)".
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(373,5): warning MSB4211: The property "CleanFile" is being set to a value for the first time, but it was already consumed at "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets (38,5)".
1>calendar.cpp
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
1>Done building project "calendar_vc9.vcxproj" -- FAILED.
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
The same fundamental problem as before.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7477
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Hello world will not compile in Release mode

Post by ONEEYEMAN »

Hi,
Which version of MSVC do you have?
Can you to build minimal sample?

Thank you.
Bryan Kelly
Earned some good credits
Earned some good credits
Posts: 117
Joined: Wed Apr 27, 2022 10:47 pm

Re: Hello world will not compile in Release mode

Post by Bryan Kelly »

About Help states:
Microsoft Visual Studio Professional 2019
Version 16.11.16
Opened this solution
"C:\WXWIDGETS\3.2.0\samples\minimal\minimal_vc17.sln"
Mode set to Debug, x86, do a build. The first half of the output is:
Build started...
1>------ Build started: Project: base, Configuration: Debug Win32 ------
2>------ Build started: Project: core, Configuration: Debug Win32 ------
2>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(39,5): warning MSB4211: The property "IntermediateOutputPath" is being set to a value for the first time, but it was already consumed at "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets (38,5)".
2>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.BuildSteps.Targets(30,5): warning MSB4211: The property "DebugType" is being set to a value for the first time, but it was already consumed at "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.BuildSteps.Targets (29,5)".
2>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(373,5): warning MSB4211: The property "CleanFile" is being set to a value for the first time, but it was already consumed at "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets (38,5)".
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(39,5): warning MSB4211: The property "IntermediateOutputPath" is being set to a value for the first time, but it was already consumed at "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets (38,5)".
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.BuildSteps.Targets(30,5): warning MSB4211: The property "DebugType" is being set to a value for the first time, but it was already consumed at "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.BuildSteps.Targets (29,5)".
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(373,5): warning MSB4211: The property "CleanFile" is being set to a value for the first time, but it was already consumed at "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets (38,5)".
1>dummy.cpp
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
1>Done building project "wx_base.vcxproj" -- FAILED.
I suspect environment variable PATH needs something but have yet to find it.
Bryan Kelly
Earned some good credits
Earned some good credits
Posts: 117
Joined: Wed Apr 27, 2022 10:47 pm

Re: Hello world will not compile in Release mode

Post by Bryan Kelly »

Working it. Changed line 159 from

Code: Select all

#include "wx/setup.h"
to

Code: Select all

#include "C:\WXWIDGETS\3.2.0\include\wx\msw\setup.h"
and it compiled.
Change it to

Code: Select all

#include "$(WXWIN)/include\wx\msw\setup.h"
and it does not compile. With or without the parens. Since WXWIN is set to "C:\WXWIDGETS\3.2.0" the second version should be better, but will not work.

BUT: Using the first and apparent working option for that include line, the linker complains:
3>LINK : fatal error LNK1104: cannot open file 'wxtiffd.lib'
A search for wxtiffd.lib in directory C:\WXWIDGETS\3.2.0 comes up empty.
Last edited by Bryan Kelly on Fri Jul 08, 2022 4:27 am, edited 1 time in total.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7477
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Hello world will not compile in Release mode

Post by ONEEYEMAN »

Hi,
No, PATH is not a problem.
Unfortunately I don't know anything about Windows 11 and its security settings. Especially the one that belong to MSVC.

So you will have to wait for someone else to chime in...

Thank you.
Bryan Kelly
Earned some good credits
Earned some good credits
Posts: 117
Joined: Wed Apr 27, 2022 10:47 pm

Re: Hello world will not compile in Release mode

Post by Bryan Kelly »

I see I was posting edits while you were posting. If you have time, please check my edits.
Thank you for your time and patience.
Post Reply