Problem linking wxWidgets to custom project using wxWidgets.props

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.
Post Reply
lviolette
In need of some credit
In need of some credit
Posts: 2
Joined: Thu Jul 02, 2020 9:53 pm

Problem linking wxWidgets to custom project using wxWidgets.props

Post by lviolette » Fri Jul 03, 2020 12:32 am

I have a VS 2019 project that I'm using wxWidgets from. I went down the path of incorporating wxWidets.props so that my Debug and Release correctly link wxbase31u.lib.
I also have a "Static Release" configuration. And what I'm finding is that cofiguration is attempting to link in wxbase31.lib (note the lack of 'u'.). There is no wxbase31.lib file. So it fails to link.

I found that the reason for this is that wxSuffix is empty. And it gets set in wx_setup.props with the following:

<PropertyGroup Label="UserMacros" Condition="('$(Configuration)'=='Debug' or '$(Configuration)'=='DLL Debug') and '$(CharacterSet)'=='Unicode'">
<wxSuffix>ud</wxSuffix>
</PropertyGroup>
<PropertyGroup Label="UserMacros" Condition="('$(Configuration)'=='Debug' or '$(Configuration)'=='DLL Debug') and '$(CharacterSet)'!='Unicode'">
<wxSuffix>d</wxSuffix>
</PropertyGroup>
<PropertyGroup Label="UserMacros" Condition="('$(Configuration)'=='Release' or '$(Configuration)'=='DLL Release') and '$(CharacterSet)'=='Unicode'">
<wxSuffix>u</wxSuffix>
</PropertyGroup>
<PropertyGroup Label="UserMacros" Condition="('$(Configuration)'=='Release' or '$(Configuration)'=='DLL Release') and '$(CharacterSet)'!='Unicode'">
<wxSuffix>
</wxSuffix>
</PropertyGroup>

Because my configuration is "Static Release", it's not matching the test for 'Release'. Is this expected? Am I doing something wrong trying to use wxwidgets.props from within my application?

If one should be able to do this... Can I recommend changing these tests to use $(Configuration.Contains('Release')) instead?

Here's a couple screen shots showing this in Visual Studio UI:

This image shows wxSuffix set as expected for Release configuration:
ReleaseLinkExpanded.JPG
Shows wxSuffx correctly set for Release configuration.
ReleaseLinkExpanded.JPG (54.36 KiB) Viewed 264 times
This image shows that the wxSuffix is not set correctly for a Static Release configuration:
StaticReleaseLinkExpanded.JPG
Shows wxSuffix not set for Static Release configuration
StaticReleaseLinkExpanded.JPG (55.62 KiB) Viewed 264 times
Thank you.
Leo.

Visual Studio 2019.
wxWidgets 3.1.2

willyywt
In need of some credit
In need of some credit
Posts: 3
Joined: Tue Jun 30, 2020 12:56 pm

Re: Problem linking wxWidgets to custom project using wxWidgets.props

Post by willyywt » Fri Jul 03, 2020 6:05 am

In short:
  1. update to a newer version of wxwidgets.props (in github wxWidgets/wxwidgets.props);
  • correct the directory name by compiling the library with 'COMPILER_PREFIX=14x', or just change the directory name from 'vc_lib' to 'vc14x_lib';
  • copy './lib' to .sln folder and don't let 'vc14x_dll' in the same directory as 'vc14x_lib'.
It seems that (in the updated version) wxwidgets.props will find the first directory that works and ignore the latter:

Code: Select all

<Choose>
    <When Condition="Exists('$(MSBuildThisFileDirectory)lib\vc$(wxToolsetVerABICompat)$(wxArchSuffix)_dll$(wxCfg)\$(wxBaseLibNamePrefix).lib')">
      <PropertyGroup Label="UserMacros">
        <wxUsingVersionABICompat>1</wxUsingVersionABICompat>
        <wxUsingDll>1</wxUsingDll>
        <wxLibOrDllDir>$(MSBuildThisFileDirectory)lib\vc$(wxToolsetVerABICompat)$(wxArchSuffix)_dll$(wxCfg)</wxLibOrDllDir>
      </PropertyGroup>
    </When>
    <When Condition="Exists('$(MSBuildThisFileDirectory)lib\vc$(wxToolsetVerABICompat)$(wxArchSuffix)_lib$(wxCfg)\$(wxBaseLibNamePrefix).lib')">
      <PropertyGroup Label="UserMacros">
        <wxUsingVersionABICompat>1</wxUsingVersionABICompat>
        <wxUsingLib>1</wxUsingLib>
        <wxLibOrDllDir>$(MSBuildThisFileDirectory)lib\vc$(wxToolsetVerABICompat)$(wxArchSuffix)_lib$(wxCfg)</wxLibOrDllDir>
      </PropertyGroup>
    </When>
    <When Condition="Exists('$(MSBuildThisFileDirectory)lib\vc$(wxToolsetVersion)$(wxArchSuffix)_dll$(wxCfg)\$(wxBaseLibNamePrefix).lib')">
      <PropertyGroup Label="UserMacros">
        <wxUsingVersion>1</wxUsingVersion>
        <wxUsingDll>1</wxUsingDll>
        <wxLibOrDllDir>$(MSBuildThisFileDirectory)lib\vc$(wxToolsetVersion)$(wxArchSuffix)_dll$(wxCfg)</wxLibOrDllDir>
      </PropertyGroup>
    </When>
    <When Condition="Exists('$(MSBuildThisFileDirectory)lib\vc$(wxToolsetVersion)$(wxArchSuffix)_lib$(wxCfg)\$(wxBaseLibNamePrefix).lib')">
      <PropertyGroup Label="UserMacros">
        <wxUsingVersion>1</wxUsingVersion>
        <wxUsingLib>1</wxUsingLib>
        <wxLibOrDllDir>$(MSBuildThisFileDirectory)lib\vc$(wxToolsetVersion)$(wxArchSuffix)_lib$(wxCfg)</wxLibOrDllDir>
      </PropertyGroup>
    </When>
So changing the configuration doesn't seems to work. As what I tried: compiling the libraries, copy the ./lib folder to the same folder with .sln, add the correct MSVC version suffix (automatically added to '14x' by 'COMPILER_PREFIX=vc14x' or manually renaming), and the Visual Studio will then work by itself. I can only change between dynamicly linked and statically linked by manipulating the files (hide ./lib/vc14x_dll to the Recycle Bin so that wxwidgets will use ./lib/vc14x_lib).

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2469
Joined: Sun Jan 03, 2010 5:45 pm

Re: Problem linking wxWidgets to custom project using wxWidgets.props

Post by PB » Fri Jul 03, 2020 6:10 am

(I assume you have _UNICODE defined in the project)

AFAIK, the .props file in 3.1.2 is broken. It was fixed here: https://github.com/wxWidgets/wxWidgets/ ... dba83ffd49

But I am not sure if it can be even used with static release when you have both static and dynamic wxWidgets build, from the discussion here:
P> I understand that the dynamic build is the default, but I was not able
P> to figure out how to tell MSVS that I want to use the static build of
P> wxWidgets.

Right now it isn't possible to do this. I've decided to prioritize using
DLLs if both are available because the official binaries are DLLs and also
because linking with them should be faster (if only because the generated
binaries are smaller).
FWIW, I have always found using the old MSVC-specific include method quite painless and flexible.

willyywt
In need of some credit
In need of some credit
Posts: 3
Joined: Tue Jun 30, 2020 12:56 pm

Re: Problem linking wxWidgets to custom project using wxWidgets.props

Post by willyywt » Fri Jul 03, 2020 6:12 am

It seems that ./build/msw/wx_setup.props doesn't allow changing configuration names other than switching between 'Debug' and 'Release', 'Win32' and 'x64'

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 4245
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Problem linking wxWidgets to custom project using wxWidgets.props

Post by ONEEYEMAN » Fri Jul 03, 2020 11:57 am

Hi,
Not yet.
Hopefully Vadim will take care of that soon.

Thank you.

lviolette
In need of some credit
In need of some credit
Posts: 2
Joined: Thu Jul 02, 2020 9:53 pm

Re: Problem linking wxWidgets to custom project using wxWidgets.props

Post by lviolette » Sun Jul 12, 2020 10:40 pm

I just updated my local copy of wx_setup.props to use Configuration.Contains('Release') in place of 'Configuration'=='Release' when setting the wxSuffix variable (and also for debug).

It now works great for me when linking to both static and dynamic wxWidgets libraries.

It would be nice to have that in wx_setup.props so I didn't have to modify my local copy. But this is fine.

Thanks for all of your assistance.
Leo.

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 4245
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Problem linking wxWidgets to custom project using wxWidgets.props

Post by ONEEYEMAN » Mon Jul 13, 2020 5:18 am

Hi,
This is done now and hopefully it will happen real soon.

Thank you.

Post Reply