Data Realms Fan Forums http://45.55.195.193/ |
|
Getting a .dll working for CC http://45.55.195.193/viewtopic.php?f=73&t=18958 |
Page 1 of 1 |
Author: | Kyred [ Fri Jun 11, 2010 12:50 am ] |
Post subject: | Getting a .dll working for CC |
I'm trying to write a .dll file for CC. This is basically a "Hello World" project, to test whether or not I can get this .dll to work in CC. I know the .dll works. It will work in a standalone Lua interpreter just fine. But, when I tried to load up in CC, I got this error: Maybe I'm missing some header files or something? Here's my source code: Compiler: gcc CCLuaExtension.h Code: #ifndef CCLUAEXTENSION_H #define CCLUAEXTENSION_H #include "lua.h" #define CCLUAEXTENSION_VERSION "CC Lua Extension 1.0" #define CCLUAEXTENSION_AUTHORS "No Name" /*-------------------------------------------------------------------------*\ * Initializes the library. \*-------------------------------------------------------------------------*/ int luaopen_CCLuaExtension(lua_State *L); #endif CCLuaExtension.c Code: #include "lua.h" #include "lualib.h" #include "lauxlib.h" #include <stdio.h> //Library includes #include "CCLuaExtension.h" #include "addition.h" static const luaL_reg mod[] = { {"addition",addition_open}, {NULL,NULL} }; int base_open(lua_State *L) { lua_pushstring(L, "_VERSION"); lua_pushstring(L, CCLUAEXTENSION_VERSION); lua_rawset(L, -3); return 1; } int luaopen_CCLuaExtension(lua_State *L) { int i; //base_open(L); for (i = 0; mod[i].name; i++) mod[i].func(L); return 0; } Addition.h Code: #ifndef ADDITON_H #define ADDITON_H #include "lua.h" int addition_open(lua_State *L); #endif Addition.c Code: #include "lua.h" #include "lualib.h" #include "lauxlib.h" #include "addition.h" static int My_Adder(lua_State *L) { //Pop the first and second numbers off the stack. double dA = lua_tonumber(L,1); double dB = lua_tonumber(L,2); //Add the two numbers and push the result back onto the stack. lua_pushnumber(L,dA + dB); return 1; } int addition_open(lua_State *L) { static const luaL_reg Map [] = { {"addshit",My_Adder}, {NULL,NULL} }; luaL_register(L,"cadd",Map); return 1; } |
Author: | Daman [ Mon Jun 14, 2010 1:14 am ] |
Post subject: | Re: Getting a .dll working for CC |
Going to install everything I need to on this slow laptop, make sure my libraries compile, and then I'll debug why your library is causing that to occur(I suspect build option differences you've set, as you're using gcc(which makes everything easier to mess up)). Should have it compiling and a reason why it didn't work here by the end of the night. Got nothing better to do up here in delaware. Edit: I can safely say it's simply because you're using gcc. Really. There's no reason to use gcc if you're developing libraries for cortex command. There are a variety of issues that could've arisen, from not compiling with the same options as CC's lua, to it simply not compiling correctly for the platform you're running it on. If you post whatever compile options you used, I'm sure someone who actually uses gcc still(lol those kinds of people exist??) might tell you what's wrong. I modified it slightly to work in MSVS 2008. Here's a rar containing the repaired solution, and a binary. Also, a lot of your methodology in the library seems pointless, but I suppose a point might be provided after you actually develop it. http://filesmelt.com/dl/ccluaextension.rar Visual C/C++ 2008 express edition is free. Acquiring professional is only a few legal clicks away. It'd make your lua life much much easier. Would anyone actually be interested if I created an updated binary tutorial? Just to clear up any confusion. |
Author: | Geti [ Mon Jun 14, 2010 7:19 am ] |
Post subject: | Re: Getting a .dll working for CC |
Daman wrote: Would anyone actually be interested if I created an updated binary tutorial? Just to clear up any confusion. |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |