@@ -23,24 +23,23 @@ void LuaEnvironment::load_module_function(const char* module, const char* name,
luaL_register(m_state, module, entry);
}
-extern "C"
+
+int32_t luaopen_libcrownlua(lua_State* L)
{
- int32_t luaopen_libcrownlua(lua_State* L)
- {
- LuaEnvironment env(L);
-
- load_vec2(env);
- load_vec3(env);
- load_mat4(env);
- load_quat(env);
- load_math(env);
- load_mouse(env);
- load_keyboard(env);
- load_accelerometer(env);
- return 1;
- }
+ LuaEnvironment env(L);
+ load_vec2(env);
+ load_vec3(env);
+ load_mat4(env);
+ load_quat(env);
+ load_math(env);
+ load_mouse(env);
+ load_keyboard(env);
+ load_accelerometer(env);
+ return 1;
} // namespace crown
@@ -22,10 +22,9 @@ private:
lua_State* m_state;
};
-{
- int32_t luaopen_libcrownlua(lua_State* L);
-}
+int32_t luaopen_libcrownlua(lua_State* L);
void load_vec2(LuaEnvironment& env);
void load_vec3(LuaEnvironment& env);
@@ -6,7 +6,7 @@ set (SRC
add_definitions(-Wl,-E)
add_library (game SHARED ${SRC})
-target_link_libraries(game crown)
+target_link_libraries(game crown crownlua)
install (TARGETS game DESTINATION bin/lua_sample)
@@ -12,6 +12,8 @@ void init()
L = luaL_newstate();
luaL_openlibs(L);
+ lua_cpcall(L, luaopen_libcrownlua, NULL);
if (luaL_loadfile(L, "/home/mikymod/test/res_linux/lua/game.raw") || lua_pcall(L, 0, 0, 0))
os::printf("error: %s", lua_tostring(L, -1));