Skip to content

Instantly share code, notes, and snippets.

@ecerulm
Created November 26, 2012 22:34
Show Gist options
  • Select an option

  • Save ecerulm/4151111 to your computer and use it in GitHub Desktop.

Select an option

Save ecerulm/4151111 to your computer and use it in GitHub Desktop.
sample lua application
all: test
test: test.cpp
g++ test.cpp -llua -L$(HOME)/tmp/lua-5.2.1/src -I$(HOME)/tmp/lua-5.2.1/src -o test
#include <iostream>
#include <lua.hpp>
#include <assert.h>
#include <queue>
using namespace std;
int main()
{
cout << "test" << endl;
std::queue<int> queue;
for(unsigned int i=0; i < 10; i++) {
queue.push(i*100);
}
lua_State *L;
L = luaL_newstate();
luaL_openlibs(L);
int error = luaL_dofile(L, "./test.lua");
if (error) {
fprintf(stderr, "%s\n", lua_tostring(L,-1));
lua_pop(L,1);
exit(1);
}
lua_close(L);
}
print("hello world")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment