How can I resolve C2733 Linking Error in Visual Studio - c++

I've been trying to compile the Adaptive Communications Environment (ACE) project in MS Visual Studio 17 2022, but have been getting a slew of related linking errors.
Below is an example:
1>C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.33.31629\include\cstdlib(23,41): error C2733: 'abs': you cannot overload a function with 'extern "C"' linkage
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt\corecrt_math.h(464,38): message : see declaration of 'abs'
This issue is obviously not originating in the ACE code, but in the code bundled in with the build tools.
My guess is there is a clash between MSVC 14.33.31629 and Windows Kit 10.
Does any one have any suggestions on a fix? Is there a compiler or pre-processor flag I can use to mitigate this? Should I use different versions of the MS Build Tool or Windows Kit?

I resolved this by upgrading my Windows SDK to version 10.0.20348.0.

Related

How to build a non-MFC C++ project with static linking to VC run-time libraries?

I know that for an MFC project built with Visual Studio, one can go to the project properties and then Configuration Properties -> General -> use of MFC and change it to Use MFC in a static library:
This works if the resulting build has to run in earlier versions of Windows without the need to install MFC or VC run-time DLLs. The resulting build will use DLLs that are already present in every installation of Windows since Windows 7 and up. (Possibly even down to Windows XP.)
Now if I create a non-MFC project, say a test C++ console application, the setting to use MFC is configured as "Use standard Windows Libraries":
But if I run the resulting binary file, say on a fresh install of Windows 7, I get this error:
So having dug around the settings, I couldn't find any way to compile it with static linking to all those newer versions of VC RT libraries. Is it there and I just don't see it?
PS. Having dug in further, I found out that I can change the "Platform Toolset" to Visual Studio 2017 - Windows XP (v141_xp), assuming that it will make it backwards compatible with Windows XP and up:
But then if I compile it, I'm getting these errors:
1>c:\program files (x86)\microsoft sdks\windows\v7.1a\include\objbase.h(239): error C2760: syntax error: unexpected token 'identifier', expected 'type specifier'
1>c:\program files (x86)\microsoft sdks\windows\v7.1a\include\dbghelp.h(1540): warning C4091: 'typedef ': ignored on left of '' when no variable is declared
1>c:\program files (x86)\microsoft sdks\windows\v7.1a\include\dbghelp.h(3056): warning C4091: 'typedef ': ignored on left of '' when no variable is declared
In this part of ObjBase.h file which has nothing to do with my test C++ console project that I just created from a Visual Studio template:
So my question is -- can I build a non-MFC C++ project that can run on older versions of Windows without the need to install VC Runtime or any other additional libraries?
Go to C / C++ -> Code Generation. Set Runtime library to Multi-threaded /MT instead of Multi-threaded Dll /MD

Missing C++ Windows Runtime Component template

I'm trying to follow Consuming a C++ library project from a Windows Phone Store app. At the first step, the article instructs us:
So, the first step is going to be to create the C++ WinRT component. You can do this by adding a new project to the solution and selecting the appropriate project type as demonstrated in Figure 2. For the purposes of this example, the project type will be “Windows Runtime Component (Windows Phone) – Visual C++” (highlighted in green) as the application calling it is a Windows Phone Store app.
The problem I am having is I don't have the C++ Windows Runtime Component template installed. And its not available online, either:
I have Visual Studio Ultimate 2012, and I have the Windows Phone SDK installed along with the Windows Phone 8.0 kit. The article does not detail a Visual Studio version, but according to the Microsoft Dev Center we need Visual Studio 2012 and above for these apps.
Where, exactly, does one find the C++ Windows Runtime Component template?
The underlying problem I am trying to solve is the missing declaration for HANDLE, VOID, etc. It appears they are not included with <windows.h>. So I'm trying to duplicate a simple "Hello World" project to see what Microsoft includes in their sample projects.
cl.exe /nologo /W4 /D_MBCS /Zi /TP /EHsc /MD /DWINAPI_FAMILY=WINAPI_FAMI
LY_PHONE_APP /AI"C:\Program Files (x86)\Windows Phone Kits\8.0\Windows Metadata"
/c test.cpp
test.cpp
...
C:\Program Files (x86)\Windows Kits\8.0\include\um\minwinbase.h(46) : error C214
6: syntax error : missing ';' before identifier 'nLength'
C:\Program Files (x86)\Windows Kits\8.0\include\um\minwinbase.h(46) : error C443
0: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files (x86)\Windows Kits\8.0\include\um\minwinbase.h(47) : error C214
6: syntax error : missing ';' before identifier 'lpSecurityDescriptor'
...
But please don't focus on this problem; focus on the missing Visual Studio templates so I can fix future problems, too.

Ancient .IDE project having errors in Visual Studio 2015 system files

I'm resurrecting an ancient project, one developed when the Visual Studio project type was "IDE". I've got everything building, except for cmath errors like:
'acoshl': ambiguous call to overloaded function
in C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\cmath.
I have no references to cmath or math.h in my code, and nothing tells me why there is a conflict with functions never referenced. Obviously, I don't want to edit system files. :)

cl.exe mismatch between compiler and library versions when building Universal app

I'm trying to build a Windows Universal app using cl.exe from the command line. I've pasted in the command line parameters from one of the Visual Studio templates, but I still can't get it working. I get the following error:
F:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\vccorlib.h(348): error C3940: 'EventRegistrationToken': identifier not found - possible mismatch between compiler and library versions. Please ensure vccorlib.h/.lib, vccorlib120.dll and c1xx.dll match
It appears that it is using the wrong include libraries.
The cl.exe command line also includes the following options for include files:
/LIBPATH:"F:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\\lib\store\amd64"
/LIBPATH:"F:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\\lib\amd64"
Fixed this by running vcvarsall.bat with the appropriate option, beforehand.

VS 2010 C++ cannot load msobj100.dll in Release mode

I have a fairly simple C++ project in Visual C++ 2010 Express on Windows 7. I have no problems compiling in Debug mode for Win32, but when I switch to Release mode for Win32 I get the following compiler error:
LINK : fatal error LNK1296: unable to load msobj100.dll
I know this question has been asked here, but I couldn't get a fix from that solution. I did a search for that file, and it is only located in C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE. Within SysWOW64 and Win32, there are files called 'msobjs.dll', but that's it. Any ideas?
Try to install the Windows SDK to your computer. These Files Should be distributed.Along with it.
See here.
Copy the missing dll file from
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE
to
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\Bin.
VC\Bin is the runtime path.
This problem also bothered me for a long time, and I had to run Release mode in another machine...
and I find the solution just now.