installing wxWidgets in Visual Studio

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.
Krimby
In need of some credit
In need of some credit
Posts: 9
Joined: Sun Jun 02, 2019 11:15 am

installing wxWidgets in Visual Studio

Post by Krimby »

I have Visual Studio Community 2019
I downloaded the wxWidgets 3.1.2 source, and unzipped it to C:\wxWidgets-3.1.2
I found wx_vc15.sin in wxwidgets root/build/msw and used it to compile the source
I started a project with the Hello World program in the docs.
It couldn't find wx.h, so I added three includes:
c:\wxwidgets-3.1.2\include\;
c:\wxwidgets-3.1.2\include\wx;
c:\wxWidgets-3.1.2\include\msvc;
As I added each one it found more of the includes it needed
Now I'm stuck. It can't open setup.h

Severity Code Description Project File Line Suppression State
Error (active) E1696 cannot open source file "../../../lib/vc_lib/mswd/wx/setup.h" mapping C:\wxWidgets-3.1.2\include\msvc\wx\setup.h 125
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: installing wxWidgets in Visual Studio

Post by doublemax »

I started a project with the Hello World program in the docs.
start with the "minimal" sample in <wxdir>/samples/minimal/
It should build out of the box.
Use the source, Luke!
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4193
Joined: Sun Jan 03, 2010 5:45 pm

Re: installing wxWidgets in Visual Studio

Post by PB »

Additionally, one is supposed to (at least) read the install guide
https://github.com/wxWidgets/wxWidgets/ ... install.md

Using wxWidgets with MSVC can be actually quite simpler than with other compilers, see the docs.
Krimby
In need of some credit
In need of some credit
Posts: 9
Joined: Sun Jun 02, 2019 11:15 am

Re: installing wxWidgets in Visual Studio

Post by Krimby »

Nope. It's .sin file wouldn't load. I loaded the project file and it was for an old version of VS, VS "updated" it, and it couldn't find includes, etc.
Krimby
In need of some credit
In need of some credit
Posts: 9
Joined: Sun Jun 02, 2019 11:15 am

Re: installing wxWidgets in Visual Studio

Post by Krimby »

I started with minimal again. This time I started with an empty project, added the minimal.cpp program, added the same 3 includes I did before.
It got about as far as the Hello World program.

Cannot open source file ..\sample.xpm
Cannot open source file ..\..\..\lib\vc_lib\mswd\wx\setup.h

I don't see a sample.xpm anywhere;
setup.h is in C:\wxWidgets-3.1.2\include\msvc\wx

Do I need to add a library directory that points to setup.h?
It seems to be looking for a library named setup.h
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: installing wxWidgets in Visual Studio

Post by doublemax »

I started with minimal again. This time I started with an empty project, added the minimal.cpp program, added the same 3 includes I did before.
It got about as far as the Hello World program.
Don't. There are too many things to set up including several preprocessor symbols. It's a pain in the *** to create a wxWidgets project from scratch.

If you were able to build wxWidgets itself with the solution files, the minimal sample should work, too.

Can you try with the latest version from GIT? https://github.com/wxWidgets/wxWidgets
Use the source, Luke!
Krimby
In need of some credit
In need of some credit
Posts: 9
Joined: Sun Jun 02, 2019 11:15 am

Re: installing wxWidgets in Visual Studio

Post by Krimby »

Can't make any sense of the GIT website.
I think I'll start over. Dump Visual Studio 2019 since it's new, and go back to a version that has wx binaries.
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: installing wxWidgets in Visual Studio

Post by doublemax »

I haven't tried VS2019 yet, but i know that with VS2017 wxWidgets and its samples build out of the box.
Use the source, Luke!
Krimby
In need of some credit
In need of some credit
Posts: 9
Joined: Sun Jun 02, 2019 11:15 am

Re: installing wxWidgets in Visual Studio

Post by Krimby »

VS 2017 looks as hard to install as 2019, so I'm sticking with 2019. Right now setup.h seems to be the problem. There's a "fake" one it starts with, in include\msvc\wx, which then calls the "real" one, which I think is in include\wx\msw, but the "fake" one is looking in the lib directory.
It's looking for ..\..\..\lib\etcetcetc. Can't imagine what directory it's starting in, to go up 3 to get to the lib directory. Seems like the "fake" one is garbage, maybe.

I'm going to keep looking for a while, but I have a feeling this is going nowhere.

I guess what I really need is just an existing project that actually works in VS 2019, and then I can just gut the program and use it as my starter.

Should I post a request to that effect in one of the forums? Or just look in the docs or something like that? Thanks for all your replies. I still can't get over how difficult this has turned out to be!
Kvaz1r
Super wx Problem Solver
Super wx Problem Solver
Posts: 357
Joined: Tue Jun 07, 2016 1:07 pm

Re: installing wxWidgets in Visual Studio

Post by Kvaz1r »

It would be better if you can say does minimal sample works for you? If it works you can just create VS-template base on it or create a new one by copying settings. If not - something went wrong and you should fix that issue first.
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: installing wxWidgets in Visual Studio

Post by doublemax »

downloaded the wxWidgets 3.1.2 source
Did you use one of the Windows archives? The Unix one has different line endings which Visual Studio doesn't like.
Use the source, Luke!
Krimby
In need of some credit
In need of some credit
Posts: 9
Joined: Sun Jun 02, 2019 11:15 am

Re: installing wxWidgets in Visual Studio

Post by Krimby »

I forgot there were all those working programs in samples, so I tried minimal and it worked. I just can't make a copy and put it in a different directory; all of it's directory paths are relative to it being in the samples directory, so I'm in the process of hardcoding them to my C:\wxWidgets directory. So far so good! Current problem is the project properties have a dozen includes starting with ..\..\, the same relative path that I'm fixing in the solution and project files. I'm hoping a "minimal" program doesn't actually use a dozen different include directories!

About the Unix format - I did have an error somewhere along the line where it said the file didn't have the normal CR/LF line endings, but I think it was just one file. Hopefully 99% of mine are correct.

Onward! Need to fix the include dir properties.
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: installing wxWidgets in Visual Studio

Post by doublemax »

Per configuration you'll need two include paths, one library path and one for resources.

And try to avoid hardcoded, absolute paths. Define an environment variable that points to your wxWidgets directory. E.g. If you name it "WXW31", you can use this as include path:
$(WXW31)\include
Use the source, Luke!
Krimby
In need of some credit
In need of some credit
Posts: 9
Joined: Sun Jun 02, 2019 11:15 am

Re: installing wxWidgets in Visual Studio

Post by Krimby »

OK, how do I define an environment variable?

include\wx\platform.h has this line: include "wx/setup.h" and can't find it.
None of these things have worked:
setup.h is in include\msvc\wx, which I added to the project properties
I have put setup.h in include\wx
I have put setup.h in include\wx\wx

My project properties:
include
include\wx
include\msvc\wx

Even if trying to include setup.h is wrong, why hasn't one of these things worked?
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: installing wxWidgets in Visual Studio

Post by doublemax »

https://www.techjunkie.com/environment- ... indows-10/
I forgot there were all those working programs in samples, so I tried minimal and it worked.
I thought you already had a working base?
I have put setup.h in include\wx
I have put setup.h in include\wx\wx
*Never* move files around to fix errors like this.

There should be two entries for include path. The first one is configuration specific. This must match the configuration you used when building wxWidgets itself. E.g. for Unicode, Debug, Static, it looks like this:
$(WXW31)\lib\vc_lib\mswud
This one must also be the first in the list

The second one is universal:
$(WXW31)\include
Use the source, Luke!
Post Reply