Error C1083 Cannot open include file: 'wx/wxprec.h': No such file or directory 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
tuk1
Experienced Solver
Experienced Solver
Posts: 92
Joined: Sun Oct 08, 2017 9:36 am

Error C1083 Cannot open include file: 'wx/wxprec.h': No such file or directory

Post by tuk1 » Sun May 24, 2020 9:29 am

I recently copied a wx project to another machine and it refused to load, so attempted to create a new project with the source files which refuses to compile due to what seems like linking issues.
1.PNG
1.PNG (37.06 KiB) Viewed 557 times
2.PNG
3.PNG
wxWidgets(v3.1.3) - Vs2019(v142) - Win10(x64) - DialogBlocks(v5.16.5_Unicode)

tuk1
Experienced Solver
Experienced Solver
Posts: 92
Joined: Sun Oct 08, 2017 9:36 am

Re: Error C1083 Cannot open include file: 'wx/wxprec.h': No such file or directory

Post by tuk1 » Sun May 24, 2020 9:31 am

4.PNG
5.PNG
Attempted to resolve using vcpkg, but same compile issues shown above:
6.PNG
6.PNG (32.48 KiB) Viewed 555 times
Minimal works fine as do other projects.

Any ideas?
wxWidgets(v3.1.3) - Vs2019(v142) - Win10(x64) - DialogBlocks(v5.16.5_Unicode)

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2469
Joined: Sun Jan 03, 2010 5:45 pm

Re: Error C1083 Cannot open include file: 'wx/wxprec.h': No such file or directory

Post by PB » Sun May 24, 2020 10:49 am

I would remove the quotes from the compiler include path (around the semicolon), i.e., the includes should be

Code: Select all

$(WXWIN)\include\msvc;$(WXWIN)\include
If you have the quotes around the semicolon, MSVS evaluates the includes as one string, instead of two separated by a semicolon. The evaluated single string obviously does not represent a valid folder.

tuk1
Experienced Solver
Experienced Solver
Posts: 92
Joined: Sun Oct 08, 2017 9:36 am

Re: Error C1083 Cannot open include file: 'wx/wxprec.h': No such file or directory

Post by tuk1 » Mon May 25, 2020 8:53 am

oops missed that, so removing the quotes seems to have resolved the wx linking issues.

However, there is something else going on, the vs on the right is an older version of the project, while the vs on the left is the new project. At first I thought the string casting(std and wx strings are still interchangeable?) error was somehow related to the new version of wx lib, but both projects in the screenie are using the same wx lib, could it be a project setting causing the compile errors?
Capture.PNG
------


The first red error in the list, although this might resolve itself if we can get to the bottom of the string casting issue:
Capture.PNG
wxWidgets(v3.1.3) - Vs2019(v142) - Win10(x64) - DialogBlocks(v5.16.5_Unicode)

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2469
Joined: Sun Jan 03, 2010 5:45 pm

Re: Error C1083 Cannot open include file: 'wx/wxprec.h': No such file or directory

Post by PB » Mon May 25, 2020 10:23 am

Are you really using wxWidgets 3.0.5 and not 3.1.x?

If you are using 3.1, I would check values of wxUSE_UNSAFE_WXSTRING_CONV and wxNO_UNSAFE_WXSTRING_CONV in your project.
wxUSE docs wrote:wxUSE_UNSAFE_WXSTRING_CONV Defined as 1 by default for compatibility, but can be set to 0 to globally disable unsafe implicit conversions in wxString class. See wxString Related Compilation Settings for more details.
wxString docs wrote:As mentioned in Implicit conversions, wxNO_UNSAFE_WXSTRING_CONV should be defined by all code using this class to opt-in safer, but not backwards-compatible, behaviour of not providing dangerous implicit conversions to C-style strings. This option is convenient when using standard build of the library as it doesn't require rebuilding it, but for custom builds it is also possible to set wxUSE_UNSAFE_WXSTRING_CONV to 0 in order to disable the implicit conversions for all applications using it.
However, by default the dangerous wxString to std::string implicit conversions are allowed, so if the above is the reason, it means you must have requested it.

tuk1
Experienced Solver
Experienced Solver
Posts: 92
Joined: Sun Oct 08, 2017 9:36 am

Re: Error C1083 Cannot open include file: 'wx/wxprec.h': No such file or directory

Post by tuk1 » Tue May 26, 2020 4:59 am

PB wrote:
Mon May 25, 2020 10:23 am
Are you really using wxWidgets 3.0.5
Yes, because its listed as 'Latest Stable Release'
PB wrote:
Mon May 25, 2020 10:23 am
However, by default the dangerous wxString to std::string implicit conversions are allowed, so if the above is the reason, it means you must have requested it.
tbh, I wouldn't even know how to make changes like this, I like default builds to avoid issues.

I use only these commands:
cd /d %WXWIN%\build\msw
nmake /f makefile.vc

But, just to be sure, deleted the build folder, extracted wx lib again from the zip and built using the commands above and still the same wxstring compile errors remain.

How exactly can I check\change the wxUSE_UNSAFE_WXSTRING_CONV setting?
wxWidgets(v3.1.3) - Vs2019(v142) - Win10(x64) - DialogBlocks(v5.16.5_Unicode)

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2469
Joined: Sun Jan 03, 2010 5:45 pm

Re: Error C1083 Cannot open include file: 'wx/wxprec.h': No such file or directory

Post by PB » Tue May 26, 2020 5:38 am

tuk1 wrote:
Tue May 26, 2020 4:59 am
How exactly can I check\change the wxUSE_UNSAFE_WXSTRING_CONV setting?
As I wrote above, the two wxString conversion-related defines are not used in wxWidgets 3.0 so the reason for your troubles must be something else.

FWIW, I downloaded wxWidgets 3.0.5 source, built it as 32-bit using MSVS 2019 Community v16.6.0 with

Code: Select all

nmake -f makefile.vc BUILD=debug
and this

Code: Select all

#include <wx/wx.h>
#include <string>

class MyApp : public wxApp
{
public:
    bool OnInit() override
    {
        wxFrame* frame = new wxFrame(nullptr, wxID_ANY, "Test");
        wxTextCtrl* textCtrl = new wxTextCtrl(frame, wxID_ANY, "abc");

        frame->Show();

        const std::string s = textCtrl->GetLineText(0);
        wxLogMessage("%s", s);

        return true;
    }
}; wxIMPLEMENT_APP(MyApp);
builds and runs as expected, so the issue is not with wxWidgets.

For starters, I would check the evaluated values of your Preprocessor definitions in the failing configuration of your project. i.e.
preproc.png
preproc.png (70.09 KiB) Viewed 414 times
BTW, you mentioned using vcpkg before. vcpkg seems to use wxWidgets 3.1.3 so I would make sure your project is really using the version you think you are (just <Ctrl>+<Alt>+<MiddleClick> somewhere in the window space not occupied by a control) and not one vcpkg somehow sneaked in...

tuk1
Experienced Solver
Experienced Solver
Posts: 92
Joined: Sun Oct 08, 2017 9:36 am

Re: Error C1083 Cannot open include file: 'wx/wxprec.h': No such file or directory

Post by tuk1 » Tue May 26, 2020 6:10 am

The project on the right is an old version of the same project, same machine and and same wx build lib.
Image

Could the issue be somehow caused by a vs project setting?
wxWidgets(v3.1.3) - Vs2019(v142) - Win10(x64) - DialogBlocks(v5.16.5_Unicode)

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2469
Joined: Sun Jan 03, 2010 5:45 pm

Re: Error C1083 Cannot open include file: 'wx/wxprec.h': No such file or directory

Post by PB » Tue May 26, 2020 6:15 am

The screenshot is the same you already posted?

As the issue is not with wxWidgets, you built wxWidgets using their defaults, it appears the problem MUST be in the project settings. That is why I asked you to check them, starting with preprocessor definitions.

EDIT
Just to make sure, the wxString to std::string conversion fails everywhere, not just on that line?

tuk1
Experienced Solver
Experienced Solver
Posts: 92
Joined: Sun Oct 08, 2017 9:36 am

Re: Error C1083 Cannot open include file: 'wx/wxprec.h': No such file or directory

Post by tuk1 » Tue May 26, 2020 6:34 am

I copied the preprocessor definitions from your screenie but no joy, yes the conversion fails everywhere.
wxWidgets(v3.1.3) - Vs2019(v142) - Win10(x64) - DialogBlocks(v5.16.5_Unicode)

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2469
Joined: Sun Jan 03, 2010 5:45 pm

Re: Error C1083 Cannot open include file: 'wx/wxprec.h': No such file or directory

Post by PB » Tue May 26, 2020 6:40 am

Well, if the old and new project are using the exactly same wxWidgets build and configuration and only the new one fails to build, the issue is within the project settings.

You need to compare them between the two projects, should be pretty easy...

tuk1
Experienced Solver
Experienced Solver
Posts: 92
Joined: Sun Oct 08, 2017 9:36 am

Re: Error C1083 Cannot open include file: 'wx/wxprec.h': No such file or directory

Post by tuk1 » Wed May 27, 2020 4:44 am

Copied the settings exactly from the old project which resulted in nearly 3000 compile errors.(how can it be?)
Reset all vc settings to default which doesn't really effect the project but did it anyway ...3000 compile errors remained.
Added the default include paths again, the same ones you told me to remove the quotes from.

Now its working perfectly but no idea why :lol:

Thanks for the help PB, got there in the end!
wxWidgets(v3.1.3) - Vs2019(v142) - Win10(x64) - DialogBlocks(v5.16.5_Unicode)

Post Reply