wxWidgets setup in Microsoft Visual Studio 2017

家住魔仙堡 提交于 2020-05-25 07:38:37

问题


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:


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




回答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.




回答3:


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




回答4:


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.




回答5:


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.



来源:https://stackoverflow.com/questions/48027403/wxwidgets-setup-in-microsoft-visual-studio-2017

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!