Skip to content
davidsiaw edited this page Sep 28, 2014 · 4 revisions

#Getting the code When you clone LuaCppInterface make sure you clone with

git clone --recursive

If you already cloned it but did not do that, simply go into the folder and go

git submodule update --init --recursive

LuaCppInterface is designed to be a static library. This is an expansion on the README.md comment on how to compile. It basically boils down to which platform you want to use it on:

#Windows

Just include the vcxproj files in the luacppinterface and lua folders. These will provide you with the lua.lib and luacppinterface.lib files you need to include into your project. You will also need to add the luacppinterface /LuaCppInterface and lua/src folders to the header search paths.

Refer to the LuaCppTest project to see how I linked it. Its simple, just lib and header.

#Linux/Mac OS X

Running autoreconf --install && ./configure && make in the repository root will give you lua/src/liblua.a and luacppinterface/LuaCppInterface/libluacppinterface.a

These are the vars I normally use for quick reference:

CXXFLAGS := -g -Wall -std=gnu++11 -I luacppinterface/LuaCppInterface  -I luacppinterface/lua/src/
LDFLAGS := -L luacppinterface/LuaCppInterface -L luacppinterface/lua/src/ -llua -lluacppinterface -lstdc++

#iOS/Mac OS X

Literally drag and drop luacppinterface.xcodeproj or luacppinterface-ios.xcodeproj into your Xcode project and add the libs to your world.

Obviously you will need to configure the header search paths.

#Android

I provide Android.mk for lua (since lua doesn't come with it) and luacppinterface. To use them:

  1. Put luacppinterface in your jni folder (cp/git clone/git submodule add, whatever you want).
  2. Add these lines to your program's Android.mk (assuming its in jni/src):
LUACPPINTERFACE_PATH := ../luacppinterface/LuaCppInterface
LUA_PATH := ../luacppinterface/lua/src

LOCAL_CFLAGS := -std=gnu++11 -fexceptions -frtti

LOCAL_C_INCLUDES := \
	$(LOCAL_PATH)/$(LUACPPINTERFACE_PATH) \
	$(LOCAL_PATH)/$(LUA_PATH) \

LOCAL_STATIC_LIBRARIES := luacppinterface lua

easy peasy lemon squeezy.

#Try It

If you can get the simplest program to work:

#include <luacppinterface.h>

int main()
{
	// You can use it on the stack
	Lua lua;
	return 0;
}

Then you can move on to the next step!

Next: The Lua Object

Clone this wiki locally