Compile fails with lua 5.2

Issue #787 resolved
created an issue

Hello, I'm a developer with the MacPorts package management system, trying to compile LÖVE on OS X so that I can make it available in MacPorts.

In MacPorts we have lua 5.2.2. I understand that LÖVE 0.8.0 is not compatible with lua 5.2 so I am building the latest code from bitbucket, revision 5b2f0515b7052e8856b2f4e8844724a8db7ad63b.

I see you have an Xcode project file, but it assumes I have the dependencies installed as OS X frameworks. In MacPorts, those dependencies are built as normal libraries, not frameworks, so I'm not using the Xcode project. Instead I've patched your code to remove the special treatment of OS X based on the LOVE_MACOSX define from several of your include files.

Initially, LÖVE's configure script failed with:

checking for library containing lua_pcall... no
configure: error: Can't LÖVE without lua

until I found that I should use the --with-luaversion=5.2 configure argument. Auto-detection of the lua version, or a message advising me to use this configure argument, would have been more helpful than this error message.

Ultimately however the build fails with:

libtool: compile:  /usr/bin/clang++ -DHAVE_CONFIG_H -I. -I.. -I. -I./modules -I./libraries -I./libraries/enet/libenet/include -I/usr/include/freetype2 -D_FILE_OFFSET_BITS=64 -isystem/opt/local/include -D_THREAD_SAFE -I/opt/local/include/SDL2 -pipe -Os -arch x86_64 -stdlib=libc++ -std=c++11 -MT libraries/enet/enet.lo -MD -MP -MF libraries/enet/.deps/enet.Tpo -c libraries/enet/enet.cpp  -fno-common -DPIC -o libraries/enet/.libs/enet.o
libraries/enet/enet.cpp:729:2: error: use of undeclared identifier 'luaL_register'
        luaL_register(l, NULL, enet_host_funcs);
libraries/enet/enet.cpp:736:2: error: use of undeclared identifier 'luaL_register'
        luaL_register(l, NULL, enet_peer_funcs);
libraries/enet/enet.cpp:751:2: error: use of undeclared identifier 'luaL_register'
        luaL_register(l, "enet", enet_funcs);
3 errors generated.

My limited research suggests that luaL_register was deleted in lua 5.2, so this seems to be a LÖVE code bug that needs to be fixed for lua 5.2 compatibility.

Comments (6)

  1. Alex Szpakowski

    LÖVE currently only supports Lua 5.2 when Lua is built with LUA_COMPAT_ALL.

    Lua 5.2 introduces several incompatibilities both in the C API and its Lua modules compared to 5.1 (and LuaJIT, to an extent), when it's not built with that flag. Many Lua C libraries don't have runtime support for both 5.1 and stock 5.2, for example the current stable version of LuaSocket (which LÖVE uses) doesn't work with stock 5.2.

    It might be preferable for you to make LÖVE require LuaJIT 2 instead of Lua 5.2 on MacPorts. Even if LÖVE could be built using Lua 5.2 without LUA_COMPAT_ALL, many games would not work with it because of the differences in the Lua APIs.

  2. ryandesign reporter

    Thanks for your quick response.

    lua in MacPorts is built with LUA_COMPAT_ALL. That is, the file src/Makefile in the lua 5.2.2 source distribution defines -DLUA_COMPAT_ALL and MacPorts does not change it.

    We also have luajit 2 in MacPorts; I'll try using that instead.

  3. Alex Szpakowski

    Ah, it looks like LÖVE's source defines LUA_COMPAT_ALL before including Lua headers, except when the ENet wrapper does it. I think LÖVE was tested with Lua 5.2 previously and it worked, but maybe it was before ENet was added.

  4. Log in to comment