Targetting Windows XP from Visual Studio 2012 when using C++ DLL - visual-c++

I am trying to execute a C# program on Windows XP (SP3) which references a managed C++ DLL compiled with VS2012. When compiling the C++ DLL, I have set the Platform Toolset to build to Windows XP (using the v110_xp option) and set minimum required version to 5.01 in linker options, and I already installed Visual C++ 2012 Redistributable Package on the Windows XP machine. But it didn't work.
Any idea on this?

As you mentioned Platform Toolset and v110_xp option, I'd risk assuming the question is about an unmanaged C++ DLL. Anyway, try compiling your DLL with the original VS 2012 distribution (no updates) and see if it works. I dealt with a similar issue caused by VS 2012 Update 2, which is described here. You could test each of your dependency DLLs (including VC++ redistributables) with DependencyWalker, to check if any of them is using a Win32 API not implemented by Windows XP. Just do it under XP itself.

Related

Targetting Windows xp from visual studio 2015 enterprise update 1

I would like to know whether we can build the projects/binaries using visual studio 2015 which can run on Windows xp ? If its supported then how we can build ?
Configuring C++ 11 Programs for Windows XP
The Windows XP platform toolset that's included in Visual Studio is a version of the Windows 7 SDK that was included in Visual Studio 2010, but it uses the current C++ compiler. It also configures project properties to appropriate default values—for example, the specification of a compatible linker for down-level targeting. Only Windows desktop apps that are created by using the Windows XP platform toolset run on Windows XP and Windows Server 2003, but those apps can also run on more recent operating systems—for example, Windows Vista, Windows 7, Windows Server 2008, Windows 8, or Windows Server 2012.
To target Windows XP
In Solution Explorer, open the shortcut menu for your project, and then choose Properties.
In the Property Pages dialog box for the project, under Configuration Properties, General, set the Platform Toolset property to the desired Windows XP toolset. For example, choose Visual Studio 2012 – Windows XP (v110_xp) to create code that is binary compatible with the Microsoft Visual C++ 2012 Redistributable libraries.
As mentioned by dxiv Windows XP can be targeted from visual studio using the correct Platform toolset (Visual Studio 2015 - Windows XP (v140_xp)).
This is not in all cases sufficient. Because the vs compiler was extended by propper thread local storage (TLS) handling there is an additional change needed. The new TLS is not properly supported by Windows XP and therefore static objects in dll's will not be initialized. If you want to avoid this problem us the additional compiler flag /Zc:threadSafeInit- to disable this problematic feature.
If you would like to use boost, you have to build it yourself. To make it compatible with Windows XP the following options have to be added :
1) run these commands before the build with b2 (bjam)
CALL "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86
SET "INCLUDE=%ProgramFiles(x86)%\Microsoft SDKs\Windows\7.1A\Include;%INCLUDE%"
SET "PATH=%ProgramFiles(x86)%\Microsoft SDKs\Windows\7.1A\Bin;%PATH%"
SET "LIB=%ProgramFiles(x86)%\Microsoft SDKs\Windows\7.1A\Lib;%LIB%"
2) use these additional options for b2
toolset=msvc-14.0
address-model=32
define=BOOST_USE_WINAPI_VERSION=0x0501
define=_USING_V110_SDK71_
linkflags=/SUBSYSTEM:CONSOLE,5.01
cxxflags="/Zc:threadSafeInit- "
Note:
the define is _USING_V110_SDK71_ not _USING_V140_SDK71_.
the space in cxxflags="/Zc:threadSafeInit- " is intentional du to a bug in b2 which would remove the trailing "-"

Can an application built with VC++ 2010 run reliably with just the VC++ 2013 redistributable installed?

So here is my situation: We have some applications built using VC++ 2010, but others are now built with VC++ 2013.
In the past, when setting up a client machine, only VC++ 2010 Redistributable was installed, but with the development of some of these applications now in VC++ 2013 we need to install the VC++ 2013 Redistributable.
I know that the Redistributable packages are installed side by side and that applications developed in VC++ 2010 will go to their appropriate file set if it exists on the machine.
But can a VC++ 2010 project run reliably with just the VC++ 2013 redistributable installed?
This question occurred to be when I saw that Microsoft named the VC++ 2010 and 2013 redistributable install files the same. For example, vcredist_x86.exe.
Thanks for your time!
No, your VS2010 built app will need msvcr100.dll (etcetera), the VS2013 installer will deploy msvcr120.dll
Doing anything to force VS2010 to use the VS2013 runtime library is very unlikely to turn out well. The new C++11 language standard has caused lots of upheaval in the runtime libraries. The good kind of upheaval, but not exactly very compatible with old compilers.
You must therefore install the VS2010 runtime libraries as well.

MSVC 2010 and MSVC 2012 are not works together

I have come accross following situation:
I had MSVC 2012 express and pro edition in my windows 8 machine. My application build and run was working fine. Now I have installed MSVC 2010 express edition. My application build works. However it crashes duing run.
I had MSVC 2010 express and pro edition in my windows 7 machine. My application build and run was working fine. Now I have installed MSVC 2012 express edition. My application build works. However it crashes duing run.
I am using qt 5.0.2 64 and 32 bit creator to build and run my application.
My question is whether MSVC 2010 and MSVC 2012 are not works together in a single machine?
Will they replace older version exe/dlls or will they conflict each other?
Is there any solution/fix without removing MSVC 2010 and MSVC 2012?
The order of installation is important - you can use VS2010 and VS2012 together (I do) but you must install VS2010 first.
Simply reinstall VS2012 and you should be ok, although you may need to use the Windows SDK registration utility after installing VS2012 to make sure that VS2010 is directed to the Windows 7 SDK.

Corrupt C runtime library?

I'm using Visual Studio Professional 2012 (with Update 2) and since I have a project that needs to be built with the VC++ 2010 toolset I also installed Visual C++ 2010 Express (with SP1).
I use the newer 2012 IDE also for the older projects. So for these projects I set the Platform Toolset to v100. And when I also set the runtime library to /MT or /MTd I get the following error:
error LNK1127: library is corrupt
for libcpmt.lib or libcpmtd.lib, depending on the configuration.
What could be wrong here?
Installation history:
VS2012 Professional
Windows 7 SDK
Uninstalled VS2012 and Windows SDK
VC++ 2010 Express
VS2012 Professional
If I understood correctly, you installed VS2010 after installing VS2012? If not, please edit your question to make it clear.
This sequence of installations is not recommended by Microsoft, and there are plenty of caveats and ReadMe's to navigate in order to find out what's happened.
I suggest that the best thing to do is to reinstall VS2012 (or do a repair install), then see what - if anything - is still broken.

Visual C++ runtime compatibility

If I compile code using the Visual C++ 2008 compiler, do I need to have the matching service pack of the runtime library for that compiled code to run correctly?
Suppose I compile code with Visual C++ 2008 compiler (any edition). Will this work with the SP1 VC++ 2008 runtime library?
Conversely, if I compile code with a Visual C++ 2008 SP1 compiler (any edition). Will this work with the RTM VC++ 2008 runtime library?
Probably.
This is part of the reason that MS introduced the idea of Side by Side assemblies. Your code specifies its preference, and the OS gets to offer the assemblies it currently has available. If there is a match, your code runs. If not, no luck.
You do have to follow all the usual guidelines for application manifests and probably make the installation of the runtime library available in your installation package in any case.

Resources