Skip to main content
gamedev.net
🔒 Locked

Lua + SDL

Started by Mizipzor 1 reply 5.5k views
Original Post
Mizipzor
Mizipzor
Im trying to get SDL to work in lua. Ive put the luaSDL.dll file i got from here into c:\lua\bin, where ive put the lua binaries. Below shows when i, from the interactive, tries to import the lib. A guide shows that I should do "SDL", but since the file is named "luaSDL.dll", how does it find the filename from that? When I try to import "luaSDL" i get this error popup box stating that dll file couldnt be found, and the error you see in the shell. Any ideas on what Im doing wrong?
Lua 5.1.2  Copyright (C) 1994-2007 Lua.org, PUC-Rio
> print (package.cpath)
.\?.dll;C:\lua\bin\?.dll;C:\lua\bin\loadall.dll
> require ("SDL")
stdin:1: module 'SDL' not found:
        no field package.preload['SDL']
        no file '.\SDL.lua'
        no file 'C:\lua\bin\lua\SDL.lua'
        no file 'C:\lua\bin\lua\SDL\init.lua'
        no file 'C:\lua\bin\SDL.lua'
        no file 'C:\lua\bin\SDL\init.lua'
        no file '.\SDL.dll'
        no file 'C:\lua\bin\SDL.dll'
        no file 'C:\lua\bin\loadall.dll'
stack traceback:
        [C]: in function 'require'
        stdin:1: in main chunk
        [C]: ?
> require ("luaSDL")
error loading module 'luaSDL' from file 'C:\lua\bin\luaSDL.dll':
        The specified module could not be found.

stack traceback:
        [C]: ?
        [C]: in function 'require'
        stdin:1: in main chunk
        [C]: ?
>
_the_phantom_
_the_phantom_
Either the docs are wrong, or the dll is named wrong; the simple way to test is to try a 'require("luaSDL")', if that works then the docs are incorrect (and you should probably tell them).

However, if that doesn't work then the dll is named wrong, so rename it and try with 'require("SDL")' instead.
Zorbfish
Zorbfish
That module is outdated. If you check the readme file it clearly states it only works with Lua 4.0. The error output mentions the package module so I assume you are using version 5.1 which is incompatible.

There are few options. One, you can download LuaSDL off of LuaForge.net. This is a derivative implementation of the same module. Another option is to use LuaX which is a custom distribution of Lua that includes SDL. Both options will require you to use something other than stock Lua though.


I do have a SDL prototype I built for Lua5.1. It was my final project topic I chose for my Computer Science degree. I haven't released it yet because its still lacking real polish but if you're interested pm me and I'll provide you a copy to play with.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.