c++luapremake

Attempt to index a nil value in premake.lua


I have made a premake.lua file for mye C++ Game Engine. But when i run premake5.exe vs2017 i get the error: Game Engine/premake5.lua:35: attempt to index a nil value if i go to line 35 where it complaines i see this:

34  filter "system:windows":
35      cppdialect "C++17"
36      staticruntime "On"
37      systemversion "latest"

i found out that if i comment out line 34 it seems to work but then proceedes to giving the same error on line 49:

49  filter "configurations:Debug": 
50      defines "BZ_DEBUG"
51      symbols "On"

if i at try to comment out all my filter fields. i get this error: Error: [string "return cfg-architecture"]:1: attempt to perform arithmetic on a table value (global 'cfg') in token: cfg-architecture

i have tried multiple versions of premake and have tried to compile multiple with different vs versions. But i get the same result every time.


Solution

  • You have extra : after your string in filter. so you try to call "some_string":cppdialect("C++17") and string doesn't have that method.

    Your code should be

    filter "system:windows"
        cppdialect "C++17"
        staticruntime "On"
        systemversion "latest"