Issue
I have installed raylib and ran the example .c files with success in VSCode and Notepad++.
I'm trying to execute the files from this repo raylib-cpp/projects/CMake
I haven't changed the files from the repo and ran the cmake command directly from VSCoode.
main.cpp
#include "raylib-cpp.hpp"
int main()
{
int screenWidth = 800;
int screenHeight = 450;
raylib::Color background(RAYWHITE);
raylib::Color textColor(LIGHTGRAY);
raylib::Window w(screenWidth, screenHeight, "raylib [core] example - basic window");
SetTargetFPS(60);
while (!w.ShouldClose())
{
BeginDrawing();
background.ClearBackground();
textColor.DrawText("Success!", 190, 200, 20);
EndDrawing();
}
return 0;
}
I tried running the commands as instructed in this github repo: raylib-CMake-example but had errors when I ran make
command from git bash in the build
folder, I tried mingw32-make
too but it didn't work. Then
I installed CMake tools extension in VSCode
and ran the Build command from the extension but got error stating:
inline variables require at least '/std:c++17' [F:\Code\CPP\Raylib\TestGames\Game2CPP\build\raylib-cpp-example.vcxproj]
I'm using Visual Studio Build Tools 2017 Release-amd64
as the kit.
When I tried running the example .c files from raylib I had to change the opengl version from 33 to 21 for the window to properly work.
My folder looks like this:
The output Log looks like this: \
[main] Building folder: Game2CPP raylib-cpp-example
[build] Starting build
[proc] Executing command: F:\Code\CPP\Raylib\cmake-3.18.2-win64-x64\bin\cmake.EXE --build f:/Code/CPP/Raylib/TestGames/Game2CPP/build --config Debug --target raylib-cpp-example -- /maxcpucount:6
[build] Microsoft (R) Build Engine version 15.9.21+g9802d43bc3 for .NET Framework
[build] Copyright (C) Microsoft Corporation. All rights reserved.
[build]
[build] glfw_objlib.vcxproj -> F:\Code\CPP\Raylib\TestGames\Game2CPP\build\_deps\raylib-build\src\external\glfw\src\glfw_objlib.dir\Debug\glfw_objlib.lib
[build] glfw.vcxproj -> F:\Code\CPP\Raylib\TestGames\Game2CPP\build\_deps\raylib-build\src\external\glfw\src\Debug\glfw3.lib
[build] raylib_static.vcxproj -> F:\Code\CPP\Raylib\TestGames\Game2CPP\build\_deps\raylib-build\src\Debug\raylib_static.lib
[build] main.cpp
[build] f:\code\cpp\raylib\testgames\game2cpp\build\_deps\raylib-cpp-src\include\./Color.hpp(206): error C7525: inline variables require at least '/std:c++17' [F:\Code\CPP\Raylib\TestGames\Game2CPP\build\raylib-cpp-example.vcxproj]
[build] f:\code\cpp\raylib\testgames\game2cpp\build\_deps\raylib-cpp-src\include\./Color.hpp(207): error C7525: inline variables require at least '/std:c++17' [F:\Code\CPP\Raylib\TestGames\Game2CPP\build\raylib-cpp-example.vcxproj]
[build] f:\code\cpp\raylib\testgames\game2cpp\build\_deps\raylib-cpp-src\include\./Color.hpp(208): error C7525: inline variables require at least '/std:c++17' [F:\Code\CPP\Raylib\TestGames\Game2CPP\build\raylib-cpp-example.vcxproj]
[build] f:\code\cpp\raylib\testgames\game2cpp\build\_deps\raylib-cpp-src\include\./Color.hpp(209): error C7525: inline variables require at least '/std:c++17' [F:\Code\CPP\Raylib\TestGames\Game2CPP\build\raylib-cpp-example.vcxproj]
[build] f:\code\cpp\raylib\testgames\game2cpp\build\_deps\raylib-cpp-src\include\./Color.hpp(210): error C7525: inline variables require at least '/std:c++17' [F:\Code\CPP\Raylib\TestGames\Game2CPP\build\raylib-cpp-example.vcxproj]
[build] f:\code\cpp\raylib\testgames\game2cpp\build\_deps\raylib-cpp-src\include\./Color.hpp(211): error C7525: inline variables require at least '/std:c++17' [F:\Code\CPP\Raylib\TestGames\Game2CPP\build\raylib-cpp-example.vcxproj]
[build] f:\code\cpp\raylib\testgames\game2cpp\build\_deps\raylib-cpp-src\include\./Color.hpp(212): error C7525: inline variables require at least '/std:c++17' [F:\Code\CPP\Raylib\TestGames\Game2CPP\build\raylib-cpp-example.vcxproj]
[build] f:\code\cpp\raylib\testgames\game2cpp\build\_deps\raylib-cpp-src\include\./Color.hpp(213): error C7525: inline variables require at least '/std:c++17' [F:\Code\CPP\Raylib\TestGames\Game2CPP\build\raylib-cpp-example.vcxproj]
[build] f:\code\cpp\raylib\testgames\game2cpp\build\_deps\raylib-cpp-src\include\./Color.hpp(214): error C7525: inline variables require at least '/std:c++17' [F:\Code\CPP\Raylib\TestGames\Game2CPP\build\raylib-cpp-example.vcxproj]
[build] f:\code\cpp\raylib\testgames\game2cpp\build\_deps\raylib-cpp-src\include\./Color.hpp(215): error C7525: inline variables require at least '/std:c++17' [F:\Code\CPP\Raylib\TestGames\Game2CPP\build\raylib-cpp-example.vcxproj]
[build] f:\code\cpp\raylib\testgames\game2cpp\build\_deps\raylib-cpp-src\include\./Color.hpp(216): error C7525: inline variables require at least '/std:c++17' [F:\Code\CPP\Raylib\TestGames\Game2CPP\build\raylib-cpp-example.vcxproj]
[build] f:\code\cpp\raylib\testgames\game2cpp\build\_deps\raylib-cpp-src\include\./Color.hpp(217): error C7525: inline variables require at least '/std:c++17' [F:\Code\CPP\Raylib\TestGames\Game2CPP\build\raylib-cpp-example.vcxproj]
[build] f:\code\cpp\raylib\testgames\game2cpp\build\_deps\raylib-cpp-src\include\./Color.hpp(218): error C7525: inline variables require at least '/std:c++17' [F:\Code\CPP\Raylib\TestGames\Game2CPP\build\raylib-cpp-example.vcxproj]
[build] f:\code\cpp\raylib\testgames\game2cpp\build\_deps\raylib-cpp-src\include\./Color.hpp(219): error C7525: inline variables require at least '/std:c++17' [F:\Code\CPP\Raylib\TestGames\Game2CPP\build\raylib-cpp-example.vcxproj]
[build] f:\code\cpp\raylib\testgames\game2cpp\build\_deps\raylib-cpp-src\include\./Color.hpp(220): error C7525: inline variables require at least '/std:c++17' [F:\Code\CPP\Raylib\TestGames\Game2CPP\build\raylib-cpp-example.vcxproj]
[build] f:\code\cpp\raylib\testgames\game2cpp\build\_deps\raylib-cpp-src\include\./Color.hpp(221): error C7525: inline variables require at least '/std:c++17' [F:\Code\CPP\Raylib\TestGames\Game2CPP\build\raylib-cpp-example.vcxproj]
[build] f:\code\cpp\raylib\testgames\game2cpp\build\_deps\raylib-cpp-src\include\./Color.hpp(222): error C7525: inline variables require at least '/std:c++17' [F:\Code\CPP\Raylib\TestGames\Game2CPP\build\raylib-cpp-example.vcxproj]
[build] f:\code\cpp\raylib\testgames\game2cpp\build\_deps\raylib-cpp-src\include\./Color.hpp(223): error C7525: inline variables require at least '/std:c++17' [F:\Code\CPP\Raylib\TestGames\Game2CPP\build\raylib-cpp-example.vcxproj]
[build] f:\code\cpp\raylib\testgames\game2cpp\build\_deps\raylib-cpp-src\include\./Color.hpp(224): error C7525: inline variables require at least '/std:c++17' [F:\Code\CPP\Raylib\TestGames\Game2CPP\build\raylib-cpp-example.vcxproj]
[build] f:\code\cpp\raylib\testgames\game2cpp\build\_deps\raylib-cpp-src\include\./Color.hpp(225): error C7525: inline variables require at least '/std:c++17' [F:\Code\CPP\Raylib\TestGames\Game2CPP\build\raylib-cpp-example.vcxproj]
[build] f:\code\cpp\raylib\testgames\game2cpp\build\_deps\raylib-cpp-src\include\./Color.hpp(226): error C7525: inline variables require at least '/std:c++17' [F:\Code\CPP\Raylib\TestGames\Game2CPP\build\raylib-cpp-example.vcxproj]
[build] f:\code\cpp\raylib\testgames\game2cpp\build\_deps\raylib-cpp-src\include\./Color.hpp(227): error C7525: inline variables require at least '/std:c++17' [F:\Code\CPP\Raylib\TestGames\Game2CPP\build\raylib-cpp-example.vcxproj]
[build] f:\code\cpp\raylib\testgames\game2cpp\build\_deps\raylib-cpp-src\include\./Color.hpp(228): error C7525: inline variables require at least '/std:c++17' [F:\Code\CPP\Raylib\TestGames\Game2CPP\build\raylib-cpp-example.vcxproj]
[build] f:\code\cpp\raylib\testgames\game2cpp\build\_deps\raylib-cpp-src\include\./Color.hpp(229): error C7525: inline variables require at least '/std:c++17' [F:\Code\CPP\Raylib\TestGames\Game2CPP\build\raylib-cpp-example.vcxproj]
[build] f:\code\cpp\raylib\testgames\game2cpp\build\_deps\raylib-cpp-src\include\./Color.hpp(230): error C7525: inline variables require at least '/std:c++17' [F:\Code\CPP\Raylib\TestGames\Game2CPP\build\raylib-cpp-example.vcxproj]
[build] f:\code\cpp\raylib\testgames\game2cpp\build\_deps\raylib-cpp-src\include\./Color.hpp(231): error C7525: inline variables require at least '/std:c++17' [F:\Code\CPP\Raylib\TestGames\Game2CPP\build\raylib-cpp-example.vcxproj]
[cmakefileapi-parser] Code model version (2.1) of cmake-file-api is unexpected. Expecting (2.0). IntelliSense configuration may be incorrect.
[cmakefileapi-parser] Code model version (2.1) of cmake-file-api is unexpected. Expecting (2.0). IntelliSense configuration may be incorrect.
[build] Build finished with exit code 1
Solution
I can see that there's an issue reported already https://github.com/RobLoach/raylib-cpp/issues/51. I guess that author's default C++ compiler's standard is set to 17, thus there are no issues on his machine. You are one step behind, however. Inline variables, as your compiler suggests, are available since C++17. It appears that you are using some older standard (not sure which, though). Not sure which is the default one for visual studio's cpp compiler.
You can set C++ standard for your project via CMake like that:
set_property(TARGET tgt PROPERTY CXX_STANDARD 11)
Considering this library seems to be 'header-only', you could set CXX_STANDARD to 17 only for your executable. If that raylib library has some objects, though, you'd have to set CXX_STANDARD to 17 in https://github.com/RobLoach/raylib-cpp/blob/master/projects/CMake/CMakeLists.txt for raylib-cpp-example
target.
Answered By - Marek Piotrowski