Skip to content
This repository was archived by the owner on Sep 25, 2020. It is now read-only.

Commit 6b809f1

Browse files
committed
Search multiple places for the SDL2 library
Linux library naming is not standardized! theres libSDL2.so, libSDL2-2.0.so, and libSDL2-2.0.so.0 without the .so
1 parent ccc4b6c commit 6b809f1

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/sdl2/init.lua

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,18 @@
22
-- Generated with dev/create-init.lua
33

44
local ffi = require 'ffi'
5-
local C = ffi.load('SDL2')
5+
local ok, C
6+
-- Search multiple places for the SDL2 library
7+
local names={'SDL2', 'SDL2-2.0', 'SDL2-2.0.so.0'}
8+
for i = 1, #names do
9+
ok, C = pcall(ffi.load, names[i])
10+
if ok then break end
11+
ok, C = pcall(ffi.load, 'lib' .. names[i])
12+
if ok then break end
13+
end
14+
if not ok then
15+
error("Failed to load the SDL2 library!")
16+
end
617
local sdl = {C=C}
718
local registerdefines = require 'sdl2.defines'
819

0 commit comments

Comments
 (0)