Search code examples
c++visual-studio-2017linkerwxwidgetslinker-errors

Linker Tools Error while configured and build wxWidgets Visual Studio 2017


Not able to configure wxwidgets in Visual Studio 2017.

Followed these steps.

  • From wxwidgets website, downloaded Source Code 'Windows 7Z' file, Version 3.1.3.
  • Run the wx_vc15.sln from build ->msw in Visual Studio 2017.
  • Build the Debub, DLL Debug, DLL Release, Relese successfully with Platform x86.

In Microsoft Visual Studio 17 V15.9.20, created an empty project. Added a simple wxWidgets program.

In project properties made the below changes - In All Configurations with Platform Win32, Set the Configuration Properties -> Character Set to Use Unicode Character Set

  • C/C++ -> Additional Include Directories -> $(WXWIN)\include\msvc;$(WXWIN)\include;
  • C/C++ -> Preprocessor -> Preprocessor Defenitions -> __WXMSW__;WXUSINGDLL;_DEBUG
  • Linker -> Additional Library Directories -> $(WXWIN)\lib\vc_dll

Made these changes in Environment Variables

  • In User variables
    • Add a new variable WXWIN and set its value to C:\Users\varun\Desktop\workspace\wxWidgets-3.1.3.
    • Path -> C:\Users\varun\Desktop\workspace\wxWidgets-3.1.3\lib\vc_dll.

In project properties Release Configurations, made these changes C/C++ -> Preprocessor -> Preprocessor Defenitions -> __WXMSW__;WXUSINGDLL;NDEBUG;

There is no code error but Linker Tools Error

Error (active)  E1097   unknown attribute "no_init_all" WxWidgets_Application_5 C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\winnt.h  

Error LNK2019 unresolved external symbol _main referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ) WxWidgets_Application_3 C:\Users\varun\Desktop\workspace\visual_studio_projects_2017\WxWidgets_Application_3\WxWidgets_Application_3\MSVCRTD.lib(exe_main.obj)

Error LNK1120 1 unresolved externals WxWidgets_Application_3 C:\Users\varun\Desktop\workspace\visual_studio_projects_2017\WxWidgets_Application_3\Debug\WxWidgets_Application_3.exe 

What could have gone wrong?


Solution

  • The first error you show is not an error at all but just some IntelliSense noise, see this bug report. The real error is not being able to find _main which seems to indicate that you're building a console application (see Properties\Linker\System\SubSystem option), so it should be fixed by just making it a Windows application instead.

    Also, while I don't see anything really wrong with your setup, I would still recommend using the official instructions instead. Notably in your case it should be as simple as:

    If you use MSVS 2010 or later IDE for building your project, simply add wxwidgets.props property sheet to (all) your project(s) using wxWidgets. You don't need to do anything else.