7

I've been trying to figure out for about 20 hours how to setup wxWidgets in Microsoft visual studio 2017. I've followed:

https://wiki.wxwidgets.org/Microsoft_Visual_C%2B%2B_Guide

https://raw.githubusercontent.com/wxWidgets/wxWidgets/WX_3_0_BRANCH/docs/msw/install.txt

and other numerous websites on how to set it up. I've even followed some of the posts in this website like and youtube:

How to set up wxWidgets 3.1.0 with Visual Studio 2015

I am literally stuck: I compiled it from source. And I believe I had no problem with it. I compiled it statically (DEBUG/RELEASE)...

Everytime I follow the tutorials and posts I get very weird messages...

Would there be anyone with a kind heart bother to spend some of his time to show me how to setup wxWidgets for Microsoft visual studio 2017 (Project Setup or something) fully?

Every answer would be appreciated :|

Sorry for not providing you guys with enough information.

https://wiki.wxwidgets.org/Microsoft_Visual_C%2B%2B_Guide

Been following the above link... The "Creating a new project by hand" didn't work

With the "Creating a new project from a sample":

Used the minimal sample instead of the internat because it had a solution file (internat didn't)...

I modified the .sln and .vcxproj file (replaced ../.. .... with the wxWidgets directory) and when tried to compile some simple code got plenty of errors like: "cannot open source file "wx.wx.h". So I went to project properties/ vc++ directories and specified the include and lib locations

Include Directories: C:\wxWidgets-3.1.0/include C:\wxWidgets-3.1.0/include/msvc

Libraries Directories C:\wxWidgets-3.1.0/lib/vc_lib

And then I got LOTS of errors like "could not open C:\wxWidgets-3.1.0\samples.RC

So I opened the project file as notepad and added the source.rc location:

ItemGroup ResourceCompile Include="C:\wxWidgets-3.1.0\samples\sample.rc" / and the source.rc disappeared, but the so 50 errors were still there:

(e.g. Error C2491 'wxBitmapButton::ms_classInfo': definition of dllimport static data member not allowed core C:\wxWidgets-3.1.0\src\common\bmpbtncmn.cpp 71)

Is there any easy way of setting up wxWidgets?

How to set up wxWidgets 3.1.0 with Visual Studio 2015

In the above link the bottom of the first answer "The next step is to copy the samples\minimal folder somewhere and start writing the code. All you will need to do is to change the Include and Lib search path."

I didn't really understand what he meant. I really need further clarification. It may solve all the horrible errors I have encountered.

This "question" may be super messy but I have no choice other than ask more experienced programmers for help...

Don't give up on me this quickly :3

  • 1
    Please update your question to indicate the specific step in a specific tutorial where things are going wrong, along with complete error messages. – antlersoft Dec 29 '17 at 19:25
  • Please post more information like a copy of the first couple of errors – axon Dec 29 '17 at 19:25
  • @DefenceWarfare, please post the errors you are receiving. Also, to check the compilation - try to compile and run the minimal sample provided with the library. If that compiles and run fine - everything is in order and you can start developing. – Igor Dec 29 '17 at 19:57
  • @Igor The minimal program in the samples file compiles fine. I don't know how to setup a project in mvs correctly... Any idea? – DefenceWarfare Dec 29 '17 at 22:03
  • @DefenceWarfare, if the minimal sample compiles fine and can be executed than you are done with building the library. To set up you own project it is recommended to copy the minimal sample solution to some directory and start putting some code in. What problems did you encounter doing that? – Igor Dec 29 '17 at 22:12
  • I've done it again and it compiled fine for the first 3 times, then I keep getting: Warning Access to the path 'c:\users\defen\source\repos\solution1\minimal\vc_mswud\minimal.exe' is denied. minimal C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.CppClean.targets and: Error LNK1104 cannot open file 'vc_mswud\minimal.exe' minimal C:\Users\Defen\source\repos\Solution1\minimal\LINK 1 – DefenceWarfare Dec 30 '17 at 12:45

7 Answers7

2

To use wxWidgets in your application, create a new Win32 project as usual, then add $WXWIN\include\msvc;$WXWIN\include to the compiler options ("Properties|C++|General|Additional Include Directories") and $WXWIN\lib\vc_lib to the linker options ("Properties|Linker|Additional Library Directories"). That's all (and it's documented here).

If you use wxWidgets as DLL, also add WXUSINGDLL to the list of definitions and replace vc_lib with vc_dll.

VZ.
  • 21,740
  • 3
  • 39
  • 42
  • That was the first thing I tried. I've tried it again and I'm getting errors like wx/wx.h source can't be found, ect... Any ideas on what I can do? – DefenceWarfare Dec 30 '17 at 09:59
  • Check that your `WXWIN` environment variable is defined, relaunch MSVS if necessary. But there is no magic: if you use the correct path to the directory containing `wx/wx.h`, it *will* be found. If you don't -- it won't. – VZ. Dec 30 '17 at 15:22
  • I have the WXWIN environment variable defined. I am seriously stuck at this. I've followed so many videos and guides but I still haven't figured it out. – DefenceWarfare Dec 30 '17 at 15:49
  • You don't need any videos and just one (correct) guide is enough. You're making some stupid mistake, like having a typo somewhere and you just need to find it. We all make mistakes and it's pretty unavoidable, you just need to learn to find and correct them as well. Again, if you put the correct include path in the compiler options, the header **will** be found. So if it isn't, the path is not correct. Check it again. – VZ. Dec 30 '17 at 17:37
  • https://wiki.wxwidgets.org/Microsoft_Visual_C%2B%2B_Guide ... look at the "Creating a new project by hand" part. It's a lot more complex than what you're saying... Even the minimal project in the samples folder has more things added in the properties. I don't think It can be a typo or something because I've been doing it for about 15 times.... – DefenceWarfare Dec 30 '17 at 17:40
  • Wiki is out of date, the above instructions are all you need. In any case, all the rest is irrelevant for your `wx/wx.h not found` problem, for this to work you only need to specify the correct include path. – VZ. Dec 30 '17 at 22:40
  • It kinda works, what you said didn't work, I had to add the include and library locations to vc++ directories. It has been working fine for a couple of hours. But now I am compiling in release mode and I'm getting: Error LNK1104 cannot open file "'C:\Users\Defen\source\repos\Minimal_Interface\Release\Minimal_Interface.exe' C:\Users\Defen\source\repos\Minimal_Interface\Minimal_Interface\LINK 1" Any ideas? – DefenceWarfare Dec 31 '17 at 11:49
  • I still keep getting the same error: Error LNK1104 cannot open file "'C:\Users\Defen\source\repos\Minimal_Interface\Release\Mini‌​mal_Interface.exe' C:\Users\Defen\source\repos\Minimal_Interface\Minimal_Interf‌​ace\LINK 1" I've closed the program from processes and it's still occuring... -.-' – DefenceWarfare Jan 04 '18 at 20:52
  • Sorry, I don't think it's productive to continue. You've done many things, some of which you described here, but probably not all, and now nobody knows what state your system/wxWidgets installation is in. My advice would be to start anew, avoid doing manual changes (no, they should not be necessary) and try to actually understand what's going on instead of just accepting as normal that things don't work (no, this is not normal at all). Good luck! – VZ. Jan 04 '18 at 21:45
  • Well it indeed isnt. I rarely ask people for help. And I was trying to get this wxWidgets setup a couple of years back, but left it to when I learn more about C++. Now I was tryna do it for days and just couldn't figure it out. Thanks is for the help I really appreciate. Good luck to you too. Will figure it out myself. – DefenceWarfare Jan 05 '18 at 09:04
2

I've been trying for many hours, just like you and, at the end the problem was that my libs are x64 and I had set x86 in Visual Studio (on the main window, to the left of the button Debug). In case it could help

eds
  • 21
  • 3
1

So using any of the xxxVC15.sln files, all I had to do to remove all of my various build errors was to go to Tools -> Get Tools and Features and install 'Windows 8.1 SDK and UCRT SDK'

Very first error I had was Windows 8 SDK related, but after that is when I had a ton of "could not find xyz" errors. Just started using Visual Studio, but apparently between 2015 and 2017, visual studio changed the location/lookup point of C libraries that cause issues in the wxMSW .sln files. Installing 'Windows 8.1 SDK and UCRT SDK' fixed it for

JoeManiaci
  • 435
  • 3
  • 15
1

All that I needed to compile wxWidgets "Hello world" Debug x64 on Visual Studio 2019:

  1. Install wxWidget
  2. Build with VS19 using <wx_dir>\build\msw\wx_vc12.sln and x64 Debug and Release configurations
  3. Close VS
  4. In new VS instance - create a new empty project
  5. Add main.cpp and in it add code from https://docs.wxwidgets.org/stable/overview_helloworld.html
  6. Changed line with wxIMPLEMENT_APP(MyApp); to wxIMPLEMENT_APP_CONSOLE(MyApp);
  7. Make some project settings:
    • add to с/с++ -> General -> Additional Include Directories - <wx_dir>\include and <wx_dir>\include\msvc
    • add to Linker -> General -> Additional Library Directories - <wx_dir>\lib\vc_x64_lib
    • For Debug add to Linker -> Input -> Additional dependencies - wxmsw30ud_core.lib;wxbase30ud.lib;
    • с/с++ -> Language -> Conformance mode - set "No". That helps me with error wxStrcoll: identifier not found

Hope it will help smb.

Francuz
  • 433
  • 5
  • 13
0

Try to use the precompiled binaries for VS2017. On C++ directories: Add /include Add /lib Evidently, for the headers, and libraries of wxWidgets, respectively. Finally, link the base, and the core library files of wxWidgets to your project. Write some standard basic example from the official website of wxWidgets. All should run fine.

Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
mik74
  • 1
0

Had the same issue after following all the instructions. Fixed by restarting my machine. I am following a tutorial that had me set an environment variable for wxWidgets and use that in the project properties under Additional Include Directories. It looked fine - when I brought up cmd and echoed %WXWIN% it showed the correct directory, so it looked like it applied without needing a restart, but Visual Studio gave the error that it couldn't open "wx\wx.h" even after restarting VS.

So, I restarted the whole machine, now it's working fine.

0

I also encountered this problem. None of the wxWidgets documentation mentioned this solution but it worked for me. I renamed the dll files in the lib subfolder of my wxWidgets folder

from: VC_X64.DLL & VC_X64.LIB

to: VCnnn_X64.DLL & VCnnn_X64.LIB

where nnn is the version number of Visual Studio.

fredv
  • 1