linuxluapremakeminko

minko / lua issue : premake5.lua:3: attempt to index global 'minko' (a nil value)


I am working with minko and managed to compile MINKO SDK properly for 3 platforms (Linux, Android, HTML5) and build all tutorials / examples. Moving on to create my own project, I followed the instructions on how to use the existing skeleton project, then using an existing example project.

(I believe there is an error in the skeleton code at this line :

auto sceneManager = SceneManager::create(canvas->context());    //does not compile

where as the example file look like this :

auto sceneManager = SceneManager::create(canvas);   //compile and generate binary

I was able to do so by modifying premake5.lua (to include more plugins) and calling script/solution_gmake_gcc.sh to generate the make solution a week ago. Today, I tried to make a new project in a new folder but calling

script/solution_gmake_gcc.sh and script/clean failed with this error:

minko-master/skel_tut/mycode/premake5.lua:3: attempt to index global 'minko' (a nil value)

Now at premake5.lua line 3 there is this line : minko.project.solution(PROJECT_NAME), however sine i am not familiar with lua at all, can anyone shed any light on the issue ? What is supposed to be declared here, why is it failing suddenly... ? (I can still modify,compile and run the code but i can't for example add more plug-ins)

PS: weirdly enough, the previously 'working' project is also failing at this point.

Thanks.


Solution

  • PROJECT_NAME = path.getname(os.getcwd()) 
    
    minko.project.application("minko-tutorial-" .. PROJECT_NAME)
    
      files { "src/**.cpp", "src/**.hpp", "asset/**" }
      includedirs { "src" }
    
      -- plugins
      minko.plugin.enable("sdl")
      minko.plugin.enable("assimp")
      minko.plugin.enable("jpeg")
      minko.plugin.enable("bullet")
      minko.plugin.enable("png")
      --html overlay
      minko.plugin.enable("html-overlay") 
    

    Assuming that's indeed your project premake5.lua file (please us the code tags next time), you should have include "script" at the beginning of the file:

    https://github.com/aerys/minko/blob/master/skeleton/premake5.lua#L1

    If you don't have this line, it will not include script/premake5.lua which is in charge of including the SDK build system files that defines everything inside the minko Lua namespace/table. That's why you get that error.

    I think you copy pasted one of the examples/tutorials premake5.lua file instead of modifying the one provided by the skeleton. The premake conf file of the examples/tutorials are different since they are included from the SDK premake files. But your app premake5.lua does the "opposite": it includes the SDK conf files rather than being included by them.

    The best practice is to edit your app's copy of the skeleton's premake5.lua (instead of copy/pasting one from the examples/tutorials).