atlcom.h build error when built for platform set to x64 - visual-c++

I am converting a existing c++ project to 64-bit version from 32-bit version. This project builds fine in 32-bit version, after converting to build for x64 platform in Configuration Manager i am getting bellow build error, are there any specific i have to inherit for 64-bit version or am i missing anything.
error C2259: 'ATL::CComObject' : cannot instantiate abstract class
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\atlmfc\include\atlcom.h
Below is the error from the output while building the project.
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\atlmfc\include\atlcom.h(2000): error C2259: 'ATL::CComObject<Base>' : cannot instantiate abstract class
with
[
Base=NAlertBand
]
due to following members:
'HRESULT IContextMenu::GetCommandString(UINT_PTR,UINT,UINT *,CHAR *,UINT)' : is abstract
C:\Program Files (x86)\Windows Kits\8.0\Include\um\shobjidl.h(2732) : see declaration of 'IContextMenu::GetCommandString'
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\atlmfc\include\atlcom.h(1989) : while compiling class template member function 'HRESULT ATL::CComCreator<T1>::CreateInstance(void *,const IID &,LPVOID *)'
with
[
T1=ATL::CComObject<NAlertBand>
]
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\atlmfc\include\atlcom.h(2096) : see reference to function template instantiation 'HRESULT ATL::CComCreator<T1>::CreateInstance(void *,const IID &,LPVOID *)' being compiled
with
[
T1=ATL::CComObject<NAlertBand>
]
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\atlmfc\include\atlcom.h(2095) : see reference to class template instantiation 'ATL::CComCreator<T1>' being compiled
with
[
T1=ATL::CComObject<NAlertBand>
]
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\atlmfc\include\atlcom.h(2091) : while compiling class template member function 'HRESULT ATL::CComCreator2<T1,T2>::CreateInstance(void *,const IID &,LPVOID *)'
with
[
T1=ATL::CComCreator<ATL::CComObject<NAlertBand>>,
T2=ATL::CComFailCreator<-2147221232>
]
NAlerts.cxx(44) : see reference to function template instantiation 'HRESULT ATL::CComCreator2<T1,T2>::CreateInstance(void *,const IID &,LPVOID *)' being compiled
with
[
T1=ATL::CComCreator<ATL::CComObject<NAlertBand>>,
T2=ATL::CComFailCreator<-2147221232>
]
NAlerts.cxx(44) : see reference to class template instantiation 'ATL::CComCreator2<T1,T2>' being compiled
with
[
T1=ATL::CComCreator<ATL::CComObject<NAlertBand>>,
T2=ATL::CComFailCreator<-2147221232>
]
QMessage.cxx
Thanks

Here is a similar thread - http://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/d6144eaa-fa37-4133-87a0-75a06633209b
Please post the rest of the errors also.

Related

MSVC2017 compiler error, Chromium build fails

So I am on:
Windows 10
MS Visual Studio 2017 (2017 build tools)
trying to build:
qt5.10.1 with QtWebEngine
using jom.exe -j4
and during the QtWebEngine build process, this happened:
[51/12427] CC obj/third_party/webrtc/common_audio/common_audio_c/sqrt_of_one_minus_x_squared.obj
[52/12427] CC obj/third_party/webrtc/common_audio/common_audio_c/complex_fft.obj
[53/12427] CXX obj/third_party/webrtc/call/call/call.obj
FAILED: obj/third_party/webrtc/call/call/call.obj
ninja -t msvc -e environment.x64 -- "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\bin\HostX64\x64/cl.exe" /nologo /showIncludes #obj/third_party/webrtc/call/call/call.obj.rsp /c ../../3rdparty/chromium/third_party/webrtc/call/call.cc /Foobj/third_party/webrtc/call/call/call.obj /Fd"obj/third_party/webrtc/call/call_cc.pdb"
C:\Qt\qt-everywhere-src-5.10.1\qtwebengine\src\3rdparty\chromium\third_party\webrtc/modules/video_coding/sequence_number_util.h(101): fatal error C1001: An internal error has occurred in the compiler.
(compiler file 'f:\dd\vctools\compiler\cxxfe\sl\p1\c\outdname.c', line 5310)
To work around this problem, try simplifying or changing the program near the locations listed above.
Please choose the Technical Support command on the Visual C++
Help menu, or open the Technical Support help file for more information
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\include\xutility(301): note: see reference to class template instantiation 'webrtc::DescendingSeqNumComp<uint16_t,0>' being compiled
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\include\xutility(301): note: see reference to variable template 'const bool is_empty_v<webrtc::DescendingSeqNumComp<unsigned short,0> >' being compiled
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\include\xtree(1078): note: see reference to class template instantiation 'std::_Tree_comp_alloc<_Traits>' being compiled
with
[
_Traits=std::_Tmap_traits<uint16_t,webrtc::NackModule::NackInfo,webrtc::DescendingSeqNumComp<uint16_t,0>,std::allocator<std::pair<const uint16_t,webrtc::NackModule::NackInfo>>,false>
]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\include\map(82): note: see reference to class template instantiation 'std::_Tree<std::_Tmap_traits<_Kty,_Ty,_Pr,_Alloc,false>>' being compiled
with
[
_Kty=uint16_t,
_Ty=webrtc::NackModule::NackInfo,
_Pr=webrtc::DescendingSeqNumComp<uint16_t,0>,
_Alloc=std::allocator<std::pair<const uint16_t,webrtc::NackModule::NackInfo>>
]
C:\Qt\qt-everywhere-src-5.10.1\qtwebengine\src\3rdparty\chromium\third_party\webrtc/modules/video_coding/nack_module.h(88): note: see reference to class template instantiation 'std::map<uint16_t,webrtc::NackModule::NackInfo,webrtc::DescendingSeqNumComp<uint16_t,0>,std::allocator<std::pair<const _Kty,_Ty>>>' being compiled
with
[
_Kty=uint16_t,
_Ty=webrtc::NackModule::NackInfo
]
[54/12427] CC obj/third_party/webrtc/common_audio/common_audio_c/refl_coef_to_lpc.obj
[55/12427] CC obj/third_party/webrtc/common_audio/common_audio_c/vector_scaling_operations.obj
[56/12427] CC obj/third_party/webrtc/common_audio/common_audio_c/spl_sqrt_floor.obj
[57/12427] CC obj/third_party/webrtc/common_audio/common_audio_c/resample_by_2.obj
[58/12427] CC obj/third_party/webrtc/common_audio/common_audio_c/webrtc_vad.obj
[59/12427] CC obj/third_party/webrtc/common_audio/common_audio_c/spl_init.obj
[60/12427] CXX obj/third_party/webrtc/common_audio/common_audio/sparse_fir_filter.obj
[61/12427] CXX obj/third_party/webrtc/common_audio/common_audio/real_fourier_ooura.obj
[62/12427] CXX obj/third_party/webrtc/common_audio/common_audio_cc/dot_product_with_scale.obj
ninja: build stopped: subcommand failed.
jom: C:\Qt\qt-everywhere-src-5.10.1\qtwebengine\src\core\Makefile.gn_run.Debug [run_ninja] Error 1
jom: C:\Qt\qt-everywhere-src-5.10.1\qtwebengine\src\core\Makefile.gn_run [debug-all] Error 2
jom: C:\Qt\qt-everywhere-src-5.10.1\qtwebengine\src\core\Makefile [sub-gn_run-pro-make_first] Error 2
jom: C:\Qt\qt-everywhere-src-5.10.1\qtwebengine\src\Makefile [sub-core-make_first] Error 2
jom: C:\Qt\qt-everywhere-src-5.10.1\qtwebengine\Makefile [sub-src-make_first] Error 2
jom: C:\Qt\qt-everywhere-src-5.10.1\Makefile [module-qtwebengine-make_first] Error 2
C:\Qt\qt-everywhere-src-5.10.1>
I found this forum with a slightly active/recent question asking about this same issue here:
Internal compiler error in outdname.c in VS15.7p3 when building Firefox webrtc code
Is there anything I can do from this point to fix this?
Downgrading my version of VS to 2015 allowed me to bypass this compiler error and compile QT successfully.

Compiler errors in standard C library headers in VS2015 - Visual C++ Console Application project

I recently created a VS2015 solution to continue development on a C++ project I had been working on. Whenever I try to build the project, I get hundreds of errors from standard C library header files such as string.h, stdio.h, etc.
To try to get to the root of the problem, I created a new, very basic, VC++ win32 console application project, wondering if I'd see the same compiler errors. Here is the code (ConsoleApplication1.cpp):
#include <string>
#include <iostream>
int main()
{
std::string s = "some data to print...";
std::cout << "Printing: " << s.c_str() << std::endl;
return 0;
}
When I attempt to compile this, I get 150+ errors, like this:
1>------ Build started: Project: ConsoleApplication1, Configuration: Release Win32 ------
1> stdafx.cpp
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\stdio.h(309): error C2144: syntax error: 'int' should be preceded by ';'
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\stdio.h(309): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\stdio.h(311): error C2144: syntax error: 'int' should be preceded by ';'
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\stdio.h(311): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\stdio.h(311): error C2086: 'int _CRTIMP_ALTERNATIVE': redefinition
1> C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\stdio.h(309): note: see declaration of '_CRTIMP_ALTERNATIVE'
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\stdio.h(317): error C2144: syntax error: 'int' should be preceded by ';'
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\stdio.h(317): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\stdio.h(317): error C2086: 'int _CRTIMP_ALTERNATIVE': redefinition
1> C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\stdio.h(309): note: see declaration of '_CRTIMP_ALTERNATIVE'
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\stdio.h(320): error C2144: syntax error: 'int' should be preceded by ';'
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\stdio.h(320): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\stdio.h(320): error C2086: 'int _CRTIMP_ALTERNATIVE': redefinition
1> C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\stdio.h(309): note: see declaration of '_CRTIMP_ALTERNATIVE'
....etc
I have tried to 'repair' Microsoft VC++ 2015 Redistributable(x86) via the Windows 'Uninstall or change a program' utility, to no avail. I also tried to repair Visual Studio 2015 as a whole.
I'm on Windows 7.
Anyone have an idea what is going on here? Am I pointed to the wrong include directory or something?
It appears you have (some of) the headers from a previous version of VS installed in your VS2015 folder. The standard headers in VS2015 are stored off in a folder tied to the version of the CRT (something like c:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt). Repairing or reinstalling VS2015 won't fix this.
I think you'll need to uninstall VS2015, completely delete the folder C:\Program Files (x86)\Microsoft Visual Studio 14.0, then reinstall it. This will likely break the other version (VS2013?) that is installed there, so you might want/need to uninstall that version instead, then repair VS2015.
The header that comes with VS2015 does not appear to have the "int _CRTIMP_ALTERNATIVE" listed in some of the error messages at those lines, while the one with VS2013 does.

VC++ CefSharp Import Win32 -> x64 error

In VS2013 Community Edition, I had a Win32 VC++ clr project I've been working on. I'm trying to use the CefSharp library, and so through nuget I've imported it.
Following the steps found here I learned I had to change from Win32 to x64 as my 'Active solution platform' to avoid this:
error : CefSharp.Common does not work correctly on 'Win32' platform. You need to specify platform (x86 / x64).
However when I follow those steps and add x64 to my project through the configuration manager, I get the following compilation errors:
1>------ Build started: Project: PROJECTNAME, Configuration: Release x64 ------
1> Main.cpp
1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\system_error(20): error C2869: 'std::errc' : has already been defined to be a namespace
1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\system_error(101): error C2146: syntax error : missing ';' before identifier 'generic_errno'
1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\system_error(101): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\system_error(101): fatal error C1903: unable to recover from previous error(s); stopping compilation
I'm not sure what is causing this or how to solve it.

VC++: Code works in VS2010 and breaks in VS2013

Edit: unlike the case in the question noted in the vote-to-close, the offending code here is CRT code, not mine. Even if it has a problem (which I'm pretty sure it doesn't), I have no way of fixing its source.
We have some legacy memory-leak tracing code that uses some CRT internals (nothing too exotic, essentially _CrtMemBlockHeader which is sort-of documented). While trying to migrate from VS2010 to VS2013 the code seems to cause sporadic build failures, and the offending part can be reduced to this:
#include <windows.h>
#define _CRTBLD
#include <..\crt\src\dbgint.h>
#include <fstream>
void Func()
{
std::ofstream myfile;
myfile << 8;
}
I.e., these 10 lines alone builds fine in VS2010 and in VS2013 give:
c:\program files (x86)\microsoft visual studio
12.0\vc\include\xlocnum(1105): error C2491: 'std::numpunct<_Elem>::id' : definition of dllimport static data member not allowed
I suspect the error message is not accurate - there are indeed several potential definitions of id, none of them at line 1105. There is also a considerable spew of warnings:
1>c:\program files (x86)\microsoft visual studio 12.0\vc\include\xlocnum(1105): warning C4273: 'id' : inconsistent dll linkage
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\xlocnum(80) : see previous definition of 'public: static std::locale::id std::numpunct<char>::id'
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\xlocnum(80) : while compiling class template static data member 'std::locale::id std::numpunct<_Elem>::id'
1> with
1> [
1> _Elem=char
1> ]
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\xlocnum(1185) : see reference to function template instantiation 'const _Facet &std::use_facet<std::numpunct<_Elem>>(const std::locale &)' being compiled
1> with
1> [
1> _Facet=std::numpunct<char>
1> , _Elem=char
1> ]
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\xlocnum(1179) : while compiling class template member function 'std::ostreambuf_iterator<char,std::char_traits<char>> std::num_put<char,std::ostreambuf_iterator<char,std::char_traits<char>>>::do_put(_OutIt,std::ios_base &,_Elem,std::_Bool) const'
1> with
1> [
1> _OutIt=std::ostreambuf_iterator<char,std::char_traits<char>>
1> , _Elem=char
1> ]
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\ostream(306) : see reference to class template instantiation 'std::num_put<char,std::ostreambuf_iterator<char,std::char_traits<char>>>' being compiled
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\ostream(292) : while compiling class template member function 'std::basic_ostream<char,std::char_traits<char>> &std::basic_ostream<char,std::char_traits<char>>::operator <<(int)'
1> c:\users\ofek\documents\visual studio 2013\projects\testcamsys2013\testcamsys2013\source.cpp(10) : see reference to function template instantiation 'std::basic_ostream<char,std::char_traits<char>> &std::basic_ostream<char,std::char_traits<char>>::operator <<(int)' being compiled
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\fstream(921) : see reference to class template instantiation 'std::basic_ostream<char,std::char_traits<char>>' being compiled
1> c:\users\ofek\documents\visual studio 2013\projects\testcamsys2013\testcamsys2013\source.cpp(9) : see reference to class template instantiation 'std::basic_ofstream<char,std::char_traits<char>>' being compiled
For now I'm pasting the definitions of _CrtMemBlockHeader and some macros around it directly to my code. But still - can anyone see what broke?
I realize it is not fully supported, but one can hope: is there a more robust way of using _CrtMemBlockHeader?
Looking at this error on my system, it seems to be only related to the #define _CRTBLD and the fstream header. The included dbgint.h is irrelevant (you can comment out that #include and still get the same error.
So, this seems to be a problem in the fstream header. Changing the order of inclusion removes the compilation errors:
#include <windows.h>
#include <fstream>
#define _CRTBLD
#include <..\crt\src\dbgint.h>
Perhaps this helps?

C4800 warning, how to find where in the source code

Is there a smart way to find the relevant places in the code when you get warnings like this? It seems the only line number shown refers to standard headers but not the actual code. I must add that the project is very large with hundreds of modules and 1MLOC+.
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\utility(138): warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xtree(1804) : see reference to function template instantiation 'std::pair<_Ty1,_Ty2>::pair<std::_Tree_iterator<_Mytree>,int>(_Other1 &&,_Other2 &&,void **)' being compiled
with
[
_Ty1=std::_Tree_iterator<std::_Tree_val<std::_Tree_simple_types<std::pair<const std::string,tpuTask >>>>,
_Ty2=bool,
_Mytree=std::_Tree_val<std::_Tree_simple_types<std::pair<const std::string,tpuTask >>>,
_Other1=std::_Tree_iterator<std::_Tree_val<std::_Tree_simple_types<std::pair<const std::string,tpuTask >>>>,
_Other2=int
]
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xtree(1804) : see reference to function template instantiation 'std::pair<_Ty1,_Ty2>::pair<std::_Tree_iterator<_Mytree>,int>(_Other1 &&,_Other2 &&,void **)' being compiled
with
[
_Ty1=std::_Tree_iterator<std::_Tree_val<std::_Tree_simple_types<std::pair<const std::string,tpuTask >>>>,
_Ty2=bool,
_Mytree=std::_Tree_val<std::_Tree_simple_types<std::pair<const std::string,tpuTask >>>,
_Other1=std::_Tree_iterator<std::_Tree_val<std::_Tree_simple_types<std::pair<const std::string,tpuTask >>>>,
_Other2=int
]
...
Your code has no problems.
But unfortunately, the code in VC standard headers is not warning-free in level 4. You can only disable that warning using the compiler option.

Resources