SDL2_Mixer not compiling on Visual Studio 2012, fix suggested

To the SDL2_Mixer maintainer: The existing Visual Studio 2012 SLN does not
compile unless Visual Studio 2010 is installed. In any case, it builds
with the Visual Studio 2010 toolset which is not what is intended. It is
entirely possible that no one has properly built SDL2_Mixer with VS2012’s
toolset to date.

This is because the PlatformToolset is set to v100 at build time. This
might be surprising, given that each project and configuration explicitly
defines it to v110 in the various .vcxproj files:


DynamicLibrary
false
v110 <— this bit

This is happening because the defaults are being inherited in the .vcxproj
files after the definition is given. This overrides the defaults.

The fix is to put the line

on the third line, right after the tag.

Remove it from the line where it is, currently.

The error message this avoids is:
C:\Program Files
(x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.Cpp.Platform.targets(42,5):
error MSB8020: The builds tools for Visual Studio 2010 (Platform Toolset =
‘v100’) cannot be found. To build using the v100 build tools, either click
the Project menu or right-click the solution, and then select “Update VC++
Projects…”. Install Visual Studio 2010 to build using the Visual Studio
2010 build tools.

Michael Labbe

Replying to my own post.

Yikes, okay… the Visual 2012 SLN that comes with SDL2_Mixer is really not
ready for a non-beta release.

I ran into a few more problems. Let me know if a patch would be
appreciated. I can commit some time next week to providing one.

(1)

The .vcxproj files are referring to the Visual Studio 2010 projects and not
the upgraded VS2012 ones:

This has the potential to cause a ton of confusion. Visual Studio is
already not best in class for determining where build settings are coming
from.

(2)

The SDL_mixer vcxproj includes SDL.lib and SDLmain.lib. This is fine when
you are building one configuration for one architecture. A better practice
is to provide them as additional library dependencies for each
configuration and architecture under linker settings in the properties
dialog.

(3)

This is an old one, but a pet peeve of mine. Referencing SDL at
"…\SDL" is bad. The library isn’t even called SDL anymore, it’s called
SDL2. You can specify an environment variable (eg: SDL2ROOT) and refer to
it in your builds: $(SDL2ROOT)\include

Thoughts on moving in this direction for VS builds?

Let me know which of these you would like patches for and I’ll put some
time aside to do them.On Tue, Sep 3, 2013 at 2:44 PM, Michael Labbe <@Michael_Labbe> wrote:

To the SDL2_Mixer maintainer: The existing Visual Studio 2012 SLN does not
compile unless Visual Studio 2010 is installed. In any case, it builds
with the Visual Studio 2010 toolset which is not what is intended. It is
entirely possible that no one has properly built SDL2_Mixer with VS2012’s
toolset to date.

This is because the PlatformToolset is set to v100 at build time. This
might be surprising, given that each project and configuration explicitly
defines it to v110 in the various .vcxproj files:


DynamicLibrary
false
v110 <— this bit

This is happening because the defaults are being inherited in the .vcxproj
files after the definition is given. This overrides the defaults.

The fix is to put the line

on the third line, right after the tag.

Remove it from the line where it is, currently.

The error message this avoids is:
C:\Program Files
(x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.Cpp.Platform.targets(42,5):
error MSB8020: The builds tools for Visual Studio 2010 (Platform Toolset =
‘v100’) cannot be found. To build using the v100 build tools, either click
the Project menu or right-click the solution, and then select “Update VC++
Projects…”. Install Visual Studio 2010 to build using the Visual Studio
2010 build tools.

Michael Labbe

Please open a bug on https://bugzilla.libsdl.org and assign it to me.

If you can send me a “diff” of your suggested changes against the latest
hg sources (http://hg.libsdl.org/SDL_mixer/), I can apply, test and
push them into the repo.

Thanks,
AndreasOn 9/3/2013 4:07 PM, Michael Labbe wrote:

Replying to my own post.

Yikes, okay… the Visual 2012 SLN that comes with SDL2_Mixer is
really not ready for a non-beta release.

I ran into a few more problems. Let me know if a patch would be
appreciated. I can commit some time next week to providing one.

(1)

The .vcxproj files are referring to the Visual Studio 2010 projects
and not the upgraded VS2012 ones:

This has the potential to cause a ton of confusion. Visual Studio is
already not best in class for determining where build settings are
coming from.

(2)

The SDL_mixer vcxproj includes SDL.lib and SDLmain.lib. This is fine
when you are building one configuration for one architecture. A
better practice is to provide them as additional library dependencies
for each configuration and architecture under linker settings in the
properties dialog.

(3)

This is an old one, but a pet peeve of mine. Referencing SDL at
"…\SDL" is bad. The library isn’t even called SDL anymore, it’s
called SDL2. You can specify an environment variable (eg: SDL2ROOT)
and refer to it in your builds: $(SDL2ROOT)\include

Thoughts on moving in this direction for VS builds?

Let me know which of these you would like patches for and I’ll put
some time aside to do them.

On Tue, Sep 3, 2013 at 2:44 PM, Michael Labbe <mike at frogtoss.com <mailto:mike at frogtoss.com>> wrote:

To the SDL2_Mixer maintainer: The existing Visual Studio 2012 SLN
does not compile unless Visual Studio 2010 is installed.  In any
case, it builds with the Visual Studio 2010 toolset which is not
what is intended.  It is entirely possible that no one has
properly built SDL2_Mixer with VS2012's toolset to date.

This is because the PlatformToolset is set to v100 at build time.
 This might be surprising, given that each project and
configuration explicitly defines it to v110 in the various
.vcxproj files:

  <PropertyGroup
Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"
Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
    <UseOfMfc>false</UseOfMfc>
<PlatformToolset>v110</PlatformToolset>       <--- this bit
  </PropertyGroup>

This is happening because the defaults are being inherited in the
.vcxproj files after the definition is given.  This overrides the
defaults.

The fix is to put the line
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />

on the third line, right after the <Project> tag.

Remove it from the line where it is, currently.

The error message this avoids is:
C:\Program Files
(x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.Cpp.Platform.targets(42,5):
error MSB8020: The builds tools for Visual Studio 2010 (Platform
Toolset = 'v100') cannot be found. To build using the v100 build
tools, either click the Project menu or right-click the solution,
and then select "Update VC++ Projects...". Install Visual Studio
2010 to build using the Visual Studio 2010 build tools.

Michael Labbe

SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org