Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Visual Studio 2013-2017 compatibility notice (Read 33699 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Visual Studio 2013-2017 compatibility notice

Tested VS versions:
[VS2013] 12.0.31101.00 Update 4
[VS2015] 14.0.22310.1 DP
[VS2017] 15.0.0+26288.10

A bug in recent Visual Studio compiler is preventing correct compilation of certain parts of the foobar2000 SDK in release mode with whole program optimization enabled.

In particular, all calls to playable_location virtual methods turn into nonsense ( disasm shows inlining of methods of one of playable_location subclasses when working with a playable_location pointer with no knowledge of what the actual implementation is ).
This leads to nonsensical pointers returned by metadb_handle::get_path() among other things.

To mitigate this, add the following switch to your compiler command-line:
/d2notypeopt

Alternatively, disable whole program optimization:
Project's Property Pages => Configuration Properties => General => Whole Program Optimization: No Whole Program Opimitzation

If you encounter further issues, you can use an older toolchain version; VS2010 was used for all foobar2000 development for several years without known issues.


Update: posted on MS Connect-
https://connect.microsoft.com/VisualStudio/...dll-environment


Update 2017, problem still there. Meh.
Microsoft Windows: We can't script here, this is bat country.

Visual Studio 2013 & 2015 compatibility notice

Reply #1
Tested VS versions:
[VS2013] 12.0.31101.00 Update 4
[VS2015] 14.0.22310.1 DP

A bug in recent Visual Studio compiler is preventing correct compilation of certain parts of the foobar2000 SDK in release mode with whole program optimization enabled.

In particular, all calls to playable_location virtual methods turn into nonsense ( disasm shows inlining of methods of one of playable_location subclasses when working with a playable_location pointer with no knowledge of what the actual implementation is ).
This leads to nonsensical pointers returned by metadb_handle::get_path() among other things.

To mitigate this, add the following switch to your compiler command-line:
/d2notypeopt

Alternatively, disable whole program optimization:
Project's Property Pages => Configuration Properties => General => Whole Program Optimization: No Whole Program Opimitzation

If you encounter further issues, you can use an older toolchain version; VS2010 was used for all foobar2000 development for several years without known issues.


Update: posted on MS Connect-
https://connect.microsoft.com/VisualStudio/...dll-environment

Although Connect hasn't been updated, this appears to be fixed in VS2015 RTM. LTCG isn't inlining the call, it's doing a regular mov ecx, [obj]; mov eax, [ecx]; call eax;. I haven't tested VS2013 Update 5 as I no longer have 2013 installed. I have concerns about the morality of having classes like this without a virtual destructor--while it's legal and can be done safely, it feels a bit like a booby-trap to me--but one shouldn't need such a thing to make the code compile correctly.

Visual Studio 2013 & 2015 compatibility notice

Reply #2
Yep confirmed fixed in VS2015 RTM.

foobar2000 SDK has been updated, VS2015 is now properly supported.

Included project file are still for VS2010 but you should have no trouble loading these into VS2015.

Also, I'm glad to inform you that the free Community Edition of VS2015 has all the features you'll ever need for making foobar2000 components; no missing resource editor etc as with old Visual Studio Express editions.
Microsoft Windows: We can't script here, this is bat country.

Visual Studio 2013 & 2015 compatibility notice

Reply #3
The first 'SDK 2015-01-15' link leads to SDK-2015-08-03.zip, the second 'SDK 2015-01-15' link leads to SDK-2015-01-14.zip

Visual Studio 2013 & 2015 compatibility notice

Reply #4
Fixed, thanks for reporting.
The link was right, just the label was wrong.
Microsoft Windows: We can't script here, this is bat country.

Visual Studio 2013 & 2015 compatibility notice

Reply #5
Working on your SDK now. We are VOX Player.
Have some partnership idea. How I can contact you Piotr?
Fixed, thanks for reporting.
The link was right, just the label was wrong.


Re: Visual Studio 2013 & 2015 compatibility notice

Reply #6
Also, I'm glad to inform you that the free Community Edition of VS2015 has all the features you'll ever need for making foobar2000 components; no missing resource editor etc as with old Visual Studio Express editions.

I'm totally new to visual studio and c++. I installed the free community 2015 edition, complete with all the updates and tried following the first steps of a tutorial I found online, but the VS2010 toolset is always missing.  I checked every component in the install wizard and even downloaded the windows 2010 platform sdk which according to some visual studio forums is the ultimate solution to the problem, but nothing changes. In the project properties window, the platform toolset drop-down list has every possible VS2015 and VS2013, but the VS2010 (v100) is listed as "not installed". What am I supposed to do?
I'm late

Re: Visual Studio 2013 & 2015 compatibility notice

Reply #7
Since you have VS2015, try foo_sample from the latest SDK. When it prompts you to upgrade compilers when you first open it, say yes.

See this thread for how to include WTL which is a requirement not mentioned when you download it.

https://hydrogenaud.io/index.php/topic,111311.0.html

Re: Visual Studio 2013 & 2015 compatibility notice

Reply #8
Since you have VS2015, try foo_sample from the latest SDK. When it prompts you to upgrade compilers when you first open it, say yes.

See this thread for how to include WTL which is a requirement not mentioned when you download it.

https://hydrogenaud.io/index.php/topic,111311.0.html

Thank you marc. I followed your instructions and updated the compilers, but the VS2010 toolset is still missing.
I'm late

Re: Visual Studio 2013 & 2015 compatibility notice

Reply #9
You don't need the v100 toolset if the upgrade went OK. Right clicking any of the projects>Properties should look like this...



edit: Just to confirm, you did click OK when opening the solution file for the first time?




Re: Visual Studio 2013 & 2015 compatibility notice

Reply #10
edit: Just to confirm, you did click OK when opening the solution file for the first time?

Yes I did, and the property page now looks like in the pic you posted.
Following yirkha's tutorial I tested my empty dll on a portable instance of foobar2000 and, if I get it right, I should be able to see it listed in the components page, but it's not there and I thought the reason was because the VS2010 toolset is missing.
I'm late

Re: Visual Studio 2013 & 2015 compatibility notice

Reply #11
You'll need to implement the componentinfo service to make the component show up on the Components page. You can do this via the DECLARE_COMPONENT_VERSION macro.

Re: Visual Studio 2013 & 2015 compatibility notice

Reply #12
You'll need to implement the componentinfo service to make the component show up on the Components page. You can do this via the DECLARE_COMPONENT_VERSION macro.

You mean what in yrkha's tutorial is described like this?

Quote
Put something like this in the empty foo_whatever.cpp file:

Code: [Select]
#include "stdafx.h"

DECLARE_COMPONENT_VERSION(
  "foo_whatever",
  "0.0.1",
  "Sample foobar2000 component.\n"
  "See http://yirkha.fud.cz/progs/foobar2000/tutorial.php"
);
That will be enough to know that our component was properly built and loaded.

Or am I supposed to do something more in order for the empty component to show up in the preferences tab?
I'm late

Re: Visual Studio 2013 & 2015 compatibility notice

Reply #13
You will need to declare a Preferences page as well. That minimal example will only make the component appear under the Components tab of Preferences, but not actually have its own page.

Re: Visual Studio 2013 & 2015 compatibility notice

Reply #14
You will need to declare a Preferences page as well. That minimal example will only make the component appear under the Components tab of Preferences, but not actually have its own page.

The problem is I cannot even get it to appear in the Components tab. After running a debug test I get an error saying it is impossible to open the "shared.lib shlwapi.lib" file. I copied the instruction as it is written in the tutorial into the project properties under Linker>Input>Additional Dependencies
Code: [Select]
$(SolutionDir)foobar2000/shared/shared.lib shlwapi.lib

Perhaps it is not written properly in the tutorial?
I'm late

Re: Visual Studio 2013 & 2015 compatibility notice

Reply #15
That's two paths, so you must be adding them as one path or something.

Re: Visual Studio 2013 & 2015 compatibility notice

Reply #16
That's two paths, so you must be adding them as one path or something.

I thought so, too, but where is the shlwapi.lib? I cannot find it in the sdk.
I'm late

Re: Visual Studio 2013 & 2015 compatibility notice

Reply #17
it should be inside C:\Program Files (x86)\Microsoft SDKs\Windows\...

Re: Visual Studio 2013 & 2015 compatibility notice

Reply #18
In other words, shlwapi.lib is part of the Windows SDK. You should not need to specify where it is located. The corresponding directory should be in the library search path by default if both the Windows SDK and Visual Studio are installed correctly.

Re: Visual Studio 2013 & 2015 compatibility notice

Reply #19
I'll try reinstalling visual studio 2015 community. Which components are actually required? Is the default installation ok?
I'm late

Re: Visual Studio 2013 & 2015 compatibility notice

Reply #20
Yep confirmed fixed in VS2015 RTM.

foobar2000 SDK has been updated, VS2015 is now properly supported.

Included project file are still for VS2010 but you should have no trouble loading these into VS2015.

Also, I'm glad to inform you that the free Community Edition of VS2015 has all the features you'll ever need for making foobar2000 components; no missing resource editor etc as with old Visual Studio Express editions.
I just upgraded my PC and I am hesitating between reinstalling my VS2010 copy or switching to this free VS 2015 edition.
Any advice ?

Re: Visual Studio 2013 & 2015 compatibility notice

Reply #21
I currently use VS2010 as the compiler from VS2015 the IDE and debugger. I'm not sure that Peter even uses 2015 right now for anything other than editing.

The last time I tried to use 2015 the compiler (v140_xp) to build a component, it crashed with an ICE (internal compiler exception) on shared.lib, which is still supplied pre-built with 2010. You're welcome to try your luck anyway.

Re: Visual Studio 2013 & 2015 compatibility notice

Reply #22
I use VS2015 Community. With v140_xp and /Zc:threadSafeInit- in 'C/C++ -> Command Line' all is fine beginning from XP SP2. Also starting from some VS version SSE/SSE2 in project is enabled by default, so that is disabled back (/arch:IA32 in C/C++ -> Code Generation -> Enable Enhanced Instruction Set) to respect old CPUs (was asked for).

Re: Visual Studio 2013 & 2015 compatibility notice

Reply #23
I may try that again, but again, the last time I tried linking to shared.lib from the latest SDK, I got an ICE and gave up. I may need to update my compiler again just to be sure.

Re: Visual Studio 2013-2017 compatibility notice

Reply #24
Problem still there in VS2017.

I have to credit MS that after adding /d2notypeopt all over the place, all our codebase appears to compile correctly.

Still, a better solution - such as a __declspec() to suppress this optimization for specific classes would be very appreciated. Being unable to compile correctly working code with default optimization settings sucks.
Microsoft Windows: We can't script here, this is bat country.