compile error for minimal sample using visual studio 2022

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.
Caofi
Experienced Solver
Experienced Solver
Posts: 60
Joined: Wed Dec 01, 2021 12:47 am

compile error for minimal sample using visual studio 2022

Post by Caofi »

Let me preface this by saying I don't know what I am doing :).

I have a small to medium size c++ project using Clion and a wsl/ubuntu backend, that creates a wsl console app. To move my project forward, I thought it would be a good idea to write a GUI interface for it, using wxWidgets and wxFormBuilder. And that is where my problems started.

For some reason I thought it would be easier to use visual studio than Clion for the GUI app, so I went ahead and set that all up in a win 10 virtual machine. I've been at this for like a day and half now, and I'm only making a little progress.

I followed all the steps here viewtopic.php?p=206365&sid=fb47892c27ab ... 0b#p206365 and I get this error:
wxWidgets libraries not found under "C:\wx\3.1.5\lib"
So I tried again, and started a new visual studio project, downloaded the wxWidgets source zip file, and opened the samples/minimal project, and after adding in wxwidgets.props ran the build. And got the same error.

VS says line 111 in wxwidgets.props is the location of the error.
So open that in notepad and find:

Code: Select all

<Target Name="CheckWXLibs">
    <Error
      Condition="'$(wxUsingDll)$(wxUsingLib)' == ''"
      Text="wxWidgets libraries not found under &quot;$(MSBuildThisFileDirectory)lib&quot;." />
  </Target>
At this point I'm stumped. And I have been googling for a long time now.

Note that I set the wxwin environment variable to c:\wx\3.1.5, the location of the wxWidgets files.
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4182
Joined: Sun Jan 03, 2010 5:45 pm

Re: compile error for minimal sample using visual studio 2022

Post by PB »

(I do not have MSVS 2022 so I cannot test it)

I assume you followed steps exactly, i.e., you have downloaded x64 binaries and put them in the folder they belong.

It may be possible that wxWidgets 3.1.5 do not recognize MSVS 2022, see https://github.com/wxWidgets/wxWidgets/ ... b5a9578def

I would try using the .props file from the GIT master with the changes shown in the link above.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7449
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: compile error for minimal sample using visual studio 2022

Post by ONEEYEMAN »

Hi,
Which prebuilt libraries did you download? What compiler was used?
If you are working with MSVC 2022 you can do the following:

1. Download wxWidgets source code (either by using Git or from the website).
2. Open the wxWidgets\build\msw\wx_vc16.sln andlet MSVC convert it to the current version
3. Select "Build -> Batch Build... -> Select ALL -> Build" and let the libraries build.
4. Open wxWidgets\samples\minimal\minimal_vc9.sln, let MSVC convert it and then select "Build -> Build solution".
5. Run the binary.

Now after that you should create a new project (completely new), use the properties file and start the development.

And if you have any more questions - feel free to ask. If thety will be related to build - you can use this same thread, if not - create a new one. ;-)

Thank you.
Caofi
Experienced Solver
Experienced Solver
Posts: 60
Joined: Wed Dec 01, 2021 12:47 am

Re: compile error for minimal sample using visual studio 2022

Post by Caofi »

Thanks PB and ONEEYEMAN for the super helpful posts!

So, here are the files I downloaded:
wxWidgets-3.1.5-headers.7z
wxMSW-3.1.5_vc14x_x64_Dev.7z
wxMSW-3.1.5_vc14x_x64_ReleaseDLL.7z

And when that failed, I additionally downloaded:
wxWidgets-3.1.5.zip

The compiler was a brand new install of Visual Studio Community 2022.

Anyway, long story short, just swapping in the new .props file from the GIT repo as suggested by PB still had the same error.
The good news is that the build process as suggested by ONEEYEMAN worked perfectly!
I now have the minimal example working :)

Heh, now the hard part begins. I have to learn how to a) use Visual Studio, b) write a GUI.
Caofi
Experienced Solver
Experienced Solver
Posts: 60
Joined: Wed Dec 01, 2021 12:47 am

Re: compile error for minimal sample using visual studio 2022

Post by Caofi »

Heh, GUI and VS have a steep learning curve ... :)

Using the given .sln for the minimal example worked with no hitches, so my next step was to try and create a new project and copy in the c++ from here https://docs.wxwidgets.org/trunk/overvi ... world.html. Let's say that took a long time. I was having heaps of problems of "no project defined errors", and not being able to add the wxwidgets.props file.

Here is what almost worked for me:
Change the environment var for wxwin to c:\wx\3.1.5\wxWidgets-3.1.5 (the build directory from earlier).
Start a new c++ project in visual studio, a windows desktop app.
Remove all the source code and related in the solutions section.
Create a new file, copy and paste in the hello world example code.
Shift it from miscellaneous to the source folder in the solutions section.
Go to the properties menu and add the wxwidgets.props file from the c:\wx\3.1.5\wxWidgets-3.1.5 directory.
Then when I finally tried to build I got this error:
Cannot open ../../../lib/vc/vc14x_x64_dll/mswud/wx/setup.h
So I copied the vc_x64_dll directory to the vc14x_x64_dll directory.
Now the build finally worked.
But when I went to run the new .exe I got a new error:
The code execution cannot proceed because wxbase315ud_vc_x64_custom.dll was not found. Reinstalling the program may fix this problem.
Anyway, something like that. I probably forgot a step or two. Do I need to add the .dlls to the path or something to fix this?
Caofi
Experienced Solver
Experienced Solver
Posts: 60
Joined: Wed Dec 01, 2021 12:47 am

Re: compile error for minimal sample using visual studio 2022

Post by Caofi »

Finally! I added
%WXWIN%\lib\vc14x_x64_dll
to the path environment variable, and now it runs!
User avatar
doublemax
Moderator
Moderator
Posts: 19102
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: compile error for minimal sample using visual studio 2022

Post by doublemax »

So I copied the vc_x64_dll directory to the vc14x_x64_dll directory.
You should never do this. Usually you just hide the issue temporarily, but you'll get more issues later.
...to the path environment variable, and now it runs!
I would recommend to use static linking, so that you don't have to worry about the DLLs.
Use the source, Luke!
Caofi
Experienced Solver
Experienced Solver
Posts: 60
Joined: Wed Dec 01, 2021 12:47 am

Re: compile error for minimal sample using visual studio 2022

Post by Caofi »

Given I have only been using VS and wxwidgets for a day now ...

1. If it is bad form to copy the directory, what is the correct way to fix the problem?
2. How do I use static linking? I went in to VS code generation and changed it from multi-threaded-debug-dll to multi-threaded-debug, and rebuilt my project. But the resulting .exe reported not finding the dll's (since I temporarily deleted the extra path variable to test it). Do I need to rebuild the entire wxwidgets project using multi-threaded-debug mode? And can I do it in the same build directory I already used, or will that stomp on something? I have it in a VM, so it is not too hard to walk back to a cleaner state before trying to rebuild the wxwidgets code.
User avatar
doublemax
Moderator
Moderator
Posts: 19102
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: compile error for minimal sample using visual studio 2022

Post by doublemax »

Caofi wrote: Thu Dec 02, 2021 11:30 pm 1. If it is bad form to copy the directory, what is the correct way to fix the problem?
Find the underlying source of the configuration mismatch. But i've never used these precompiled libs, so i can't tell where exactly to look.
wxWidgets-3.1.5-headers.7z
wxMSW-3.1.5_vc14x_x64_Dev.7z
wxMSW-3.1.5_vc14x_x64_ReleaseDLL.7z
I'm not a big fan of these precompiled libraries. Especially when using VS where it's very easy to build the wxWidgets libraries yourself.
Caofi wrote: Thu Dec 02, 2021 11:30 pm 2. How do I use static linking? I went in to VS code generation and changed it from multi-threaded-debug-dll to multi-threaded-debug, and rebuilt my project.
This changes the CRTs from dynamic to static. But i meant to change the use of wxWidgets from dynamic to static linking. But it seems the precompiled binaries always use DLLs. So i guess you'll have to live with that or build wxWidgets yourself.

If you wanted to build wxWidgets yourself:
- download wxWidgets sources and unpack
- go to <wxdir>\build\msw\ and open wx_vc16.sln (in general, the highest version that's equal or lower to your VS version)
- build the configurations "Debug" and "Release" instead of "Debug DLL" and "Release DLL".
Use the source, Luke!
Caofi
Experienced Solver
Experienced Solver
Posts: 60
Joined: Wed Dec 01, 2021 12:47 am

Re: compile error for minimal sample using visual studio 2022

Post by Caofi »

OK. Another day passes ... And still no dice.

So, I have done a full batch build of wxWidgets and that worked just fine.
I added C:\wx\wxWidgets-3.1.5 to the environment variable WXWIN.
I started a new C++ Windows Desktop App project template.
I went through the solutions window and removed all the files.
Copied the code from here https://docs.wxwidgets.org/trunk/overvi ... world.html to the ProjectName.cpp file.
Went to view->Other windows->PropertyManager.
Right clicked on ProjectName, then Add Existing Property Sheet.
Then went to the wxWidgets-3.1.5 dir, and found wxwidgets.props file, and selected it.

Then the total project errors went from 33 to 17. So, the wxwidgets.props file did something, or else the error count wouldn't have improved.
But now I have header issues of some sort.
wxApp works fine, but wxFrame and wxMenu, and some others are not recognized.

I presumed they should be included from this code:

Code: Select all

#include <wx/wxprec.h>
#ifndef WX_PRECOMP
#include <wx/wx.h>
#endif
As for static vs dynamic linking, I was going to follow the directions here: viewtopic.php?f=19&t=46212.

Stupid newb question: given I downloaded and compiled the source, presumably I don't need the separate header files. They are just for those downloading pre-built binaries, right?

Then under project properties, I have VC++ Directories/ Include Directories:
$(WXWIN)\include;$(WXWIN)\include\msvc;

I'm missing something stupid here.....
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4182
Joined: Sun Jan 03, 2010 5:45 pm

Re: compile error for minimal sample using visual studio 2022

Post by PB »

(I did not read all the posts above)
Caofi wrote: Fri Dec 03, 2021 7:10 am I'm missing something stupid here.....
I think you should select a way you want to do it, pick a guide and follow it exactly, not skipping or changing any step, setting all project properties (preprocessor defines, paths...) as instructed.

For example, when using MSVC-specific setup.h to autolink the libraries, both the official instructions and my guide clearly say to put the MSVC-specifc include before the main one. Yet, you do it other way around.

FWIW, I think renaming the DLL folder (vc14x_x64_dll) was fine, but in any way, could be avoided by setting the relevant wxMSVC_xxx define(s).

I think when following instructions, building wxWidgets and applications using it is very simple. You already spent so much time and effort on this simple thing, it must be very frustrating. I would take a deep breath, select a way: Using pre-built or self-built wxWidgets, delete everything I have, and start with a clean slate.

Perhaps the only issue I can see is using wxWidgets 3.1.5 with a compiler it is not aware of: MSVS 2022 released less than a month ago.

EDIT
I have installed MSVS 2022 (v17.02, Community) and tried to use prebuilt 3.1.5 x-64 binaries with it. It did not work out of the box, I got the same issue the OP had. When using the .props file from the GIT master, I got a surprising error about <stddef.h> missing. So I created a "Windows Desktop Application" project and tried to built. This also failed, this time with another standard header missing (ctype.h), which indicates my fresh MSVS 2022 installation must be badly broken. I made a mistake of importing my MSVS 2019 settings to MSVS 2022, which may be the reason. Trying to reset the settings did not help nor did the full uninstall and install, they are still there. I gave up for now.

EDIT2
I have "fixed" the missing-standard-headers issue with MSVS 2022 by installing also Windows 11 SDK together with Windows 10 one (the now-working project still uses WIndows 10 SDK though?). Following my pre-built binaries guide, a project did not compile with wxwidgets.props from 3.1.5 (same issue as the OP); however, after overwriting the file with one from the GIT master, the project built and ran successfully. But I am not sure if doing that is the best way. If I wanted to live on the edge, using the most recent and unproven software, I would go with MSVS 2022 and wxWidgets master, otherwise, I would go with tested-and-proven MSVS 2019.
Caofi
Experienced Solver
Experienced Solver
Posts: 60
Joined: Wed Dec 01, 2021 12:47 am

Re: compile error for minimal sample using visual studio 2022

Post by Caofi »

Oh I see. Well, that makes me feel better, if it is VS 2022 that is to blame!
Thankfully I have been working in a VM, so I could keep resetting and trying again from a blank slate.
I followed the steps in the guide you linked to and checked over and over that I didn't miss any steps, and I still had 17 errors.
Including <wx/frame.h> reduced that to 12, but I still couldn't get wxMenu to be recognized even after adding a <wx/menu.h> include.
Other classes had the same error.

So, I'm going to go back to an even earlier VM snapshot and try VS 2019. But I don't have the energy just right now :).

For reference, I'm using:
Microsoft Visual Studio Community 2022 (64-bit)
Version 17.0.1
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4182
Joined: Sun Jan 03, 2010 5:45 pm

Re: compile error for minimal sample using visual studio 2022

Post by PB »

Caofi wrote: Fri Dec 03, 2021 11:38 pm Oh I see. Well, that makes me feel better, if it is VS 2022 that is to blame!
As I wrote, I was able to fix it. You can easily tell if your MSVS 2022 install is working by compiling a simple Win32 application generated by the project wizard
Caofi wrote: Fri Dec 03, 2021 11:38 pm I followed the steps in the guide you linked to and checked over and over that I didn't miss any steps, and I still had 17 errors.
I do not know which guide you mean but if your system is working, they should work.

You really need to paste the error messages, which will tell what is wrong.
Caofi
Experienced Solver
Experienced Solver
Posts: 60
Joined: Wed Dec 01, 2021 12:47 am

Re: compile error for minimal sample using visual studio 2022

Post by Caofi »

Just an update. For a while I couldn't log into the forums, hence the delayed response.
Anyway, thanks for all the help! I now have the basics working.
I have menu's, some of them auto-populated from a std::set, I have a decent(ish) looking About box. An open and close widget, and a wxListCtrl dialog.
Though I'm having heaps of trouble getting the wxListCtrl to sort when I click on the headers. I will post elsewhere about that.
Wip
In need of some credit
In need of some credit
Posts: 8
Joined: Thu Dec 16, 2021 4:56 pm

Re: compile error for minimal sample using visual studio 2022

Post by Wip »

Hello, I got the same problem as above.

The code execution cannot proceed because wxbase315ud_vc_x64_custom.dll was not found. Reinstalling the program may fix this problem.

I'm running:
-windows 10
-Visual Studio 2022 1703
-wxWidget 3.1.5

I downloaded the zip
Compiled it with vs code 2022
I set an ambient variable callse WXWIN.
I created a project by using the props from github because I read on the forum that they're better for 2022 (I can confirm i tried the original too).

(I tried without the props by configuring manually by folowing 2 different toutorial and a guide on this forum but nothing worked till now and I'm getting pretty desperate XD)

I tried to compile the hello world sample.

It's the first time I'm using this and I don't really know where I shoud look.

Thanks in advance for your help/time.
Post Reply