Trouble building and using Lua for 32-bit on 64-bit OS X

时间:2016-10-09 15:51:33

标签: c++ c gcc makefile lua

I'm having difficulties using my built Lua.

To build my small project, I'm using:

gcc -m32 -arch i386 -I ~/Documents/lua-5.1.4/include -L ~/Documents/lua-5.1.4/lib -llua -mconsole -sectcreate __TEXT __info_plist ./Info.plist -o LuaProject -masm=intel LuaProject.cpp

I built Lua with "make macosx test". To try to make it build 32-bit, I modified the src/Makefile so that the top became:

CC= gcc
CFLAGS= -m32 -arch i386 -O2 -Wall $(MYCFLAGS)
AR= ar rcu
RANLIB= ranlib
RM= rm -f
LIBS= -lm $(MYLIBS)

MYCFLAGS=
MYLDFLAGS= -m32 -arch i386
MYLIBS=

That seemed to make it for 32-bit. All I did was add -m32 -arch i386 to CFLAGS (MYCFLAGS wasn't affecting anything) and -m32 -archi386 to MYLDFLAGS. After it worked for neither -m32 nor -arch i386 individually I added both (perhaps not the best logic) which changed nothing. The build works, so then I "sudo make install local", which creates the nice folders I used to try to compile my project.

The output from gcc ends up being:

Undefined symbols for architecture i386:

  "luaL_newstate()", referenced from:
      _main in LuaProject-15f700.o
  "luaL_openlibs(lua_State*)", referenced from:
      _main in LuaProject-15f700.o
  "luaL_loadbuffer(lua_State*, char const*, unsigned long, char const*)", referenced from:
      _main in LuaProject-15f700.o
  "lua_pcall(lua_State*, int, int, int)", referenced from:
      _main in LuaProject-15f700.o
ld: symbol(s) not found for architecture i386

I am hopefully including all I need to (lua.h, lauxlib.h, lualib.h) and no errors are thrown about the -llua itself, so I am confused as to why this isn't working.

I didn't want to clutter the question with the full Lua makefile but I can upload it if needed.

0 个答案:

没有答案