gwaldron / osgearth

3D Maps for OpenSceneGraph / C++14
https://www.pelicanmapping.com/home-1/opensource
Other
1.47k stars 772 forks source link

use Visual Studio 2022 Build error #2503

Closed gfyrtuwcv closed 4 months ago

gfyrtuwcv commented 4 months ago

Runtime inulde files error

I use Visual Studio 17 2022 build newest osgearth then use it to run [Getting Started - Documentation(http://docs.osgearth.org/en/latest/)‘s frist Sample main.cpp build failure and some error occurred about include:

E:\OSG\osgearth3.5-Debug\include\osgEarth\weejobs.h(224,43): error C2039: "result_of": is not "std"’s member [E:\source\earthTes t\build\earthTest.vcxproj] E:\OSG\osgearth3.5-Debug\include\osgEarth\weejobs.h(224,55): error C2653: "result_of" : not a class or namespace name [E:\source\earthTest\build\earthTest.vcxproj] (Compile source file "... /earthTest.cpp”) E:\OSG\osgearth3.5-Debug\include\osgEarth\weejobs.h(24,57): error C2061: Syntax error: identifier "type" [E:\source\earthTest\build\earthTest.vcxproj] (Compile source file "... /earthTest.cpp”) E:\OSG\osgearth3.5-Debug\include\osgEarth\weejobs.h(233,12): error C2631: "jobgroup" : Classes or enumerations cannot be defined in the alias template [E:\source\earthTest\build\earthTest.vcxproj] (Compile source file "... /earthTest.cpp”) E:\OSG\osgearth3.5-Debug\include\osgEarth\Threading(27,1): error C2988: unrecognized template declaration/definition [E:\source\earthTest\build\earthTest.vcxproj] (Compile source file "... /earthTest.cpp”) E:\OSG\osgearth3.5-Debug\include\osgEarth\Threading(27,1): error C2059: Syntax error: "" [E:\source\earthTest\build\e arthTest.vcxproj] (Compile source file "... /earthTest.cpp”) E:\OSG\osgearth3.5 -debug \include\osgEarth\Threading(28,1): error C4430: Missing type specifier - assumed int. Note: C++ does not support tacit int [E:\source\ earthTest\build\earthTest.vcxproj] (Compile source file "... /earthTest.cpp”) E:\OSG\osgearth3.5-Debug\include\osgEarth\Threading(32,5): error C2988: unrecognized template declaration/definition [E:\source\earthTest\build\earthTest.vcxproj] (Compile source file "... /earthTest.cpp”) E:\OSG\osgearth3.5-Debug\include\osgEarth\Threading(32,5): error C2059: Syntax error: "using" [E:\source\earthTest\build\earthTe st.vcxproj] (Compile source file "... /earthTest.cpp”) E:\OSG\osgearth3.5-Debug\include\osgEarth\Threading(42,38): error C2908: explicit specialization; Instantiated "std::lock_guard" [E:\source\earthTest\build\earthTest.vcxproj] (Compile source file "... /earthTest.cpp”) E:\OSG\osgearth3.5-Debug\include\osgEarth\Threading(42,38): error C2906: "std::lock_guard" : Explicit specialization requires "template <>” [E:\source\earthTest\build\earthTest.vcxproj] (Compile source file "... /earthTest.cpp”) E: \ OSG \ osgearth3.5 - Debug \ include \ osgEarth \ Threading (43,47) : error C2906: "STD: : lock_guard < jobs: : Threading: : RecursiveMutex> ": Explicit specialization requires" template <> "[E:\source\earthTest\build\ earthtest.vcxproj] (Compile source file "... /earthTest.cpp”) E:\OSG\osgearth3.5-Debug\include\osgEarth\Threading(45,73): error C2039: "future": not a member of "jobs" [E:\source\earthTest\b uild\earthTest.vcxproj] (Compile source file "... /earthTest.cpp”) E: \ OSG \ osgearth3.5 - Debug \ include \ osgEarth \ weejobs h (46, 11) :See "jobs" announcement E:\OSG\osgearth3.5-Debug\include\osgEarth\Threading(45,73): error C7568: The assumed function template "future" is missing a parameter list [E:\source\earthTest\build\earthTest.vcxproj] (Compile source file "... /earthTest.cpp”) E:\OSG\osgearth3.5-Debug\include\osgEarth\Threading(45,73): error C2062: unexpected type "unknown" [E:\source\earthTest\buil d\earthTest.vcxproj] (Compile source file "... /earthTest.cpp”) E:\OSG\osgearth3.5-Debug\include\osgEarth\Threading(61,36): error C2631: "ReadWrite" : Classes or enumerations cannot be defined in the alias template [E:\source\earthTes E:\OSG\osgearth3.5-Debug\include\osgEarth\Threading(252,1): error C1903: Cannot recover from previous error. Stopping compilation

I use vcpkg install osgearth3.4 build is not cause this problem How can I fix it?

gwaldron commented 4 months ago

It almost seems like you are compiling without C++11 support. Try adding this to your CMakeLists.txt:

set_property(GLOBAL PROPERTY CXX_STANDARD 11)
set_property(GLOBAL PROPERTY CXX_STANDARD_REQUIRED ON)
gfyrtuwcv commented 4 months ago

Thank you for your reply,and I misset the C++ version earlier,now that problem is solved