View unanswered posts | View active topics It is currently Fri Dec 27, 2024 8:53 am



Reply to topic  [ 3 posts ] 
 Getting a .dll working for CC 
Author Message
User avatar

Joined: Sun May 31, 2009 1:04 am
Posts: 308
Reply with quote
Post 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:
Image

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;
}


Fri Jun 11, 2010 12:50 am
Profile
User avatar

Joined: Fri Jan 26, 2007 3:22 am
Posts: 1451
Reply with quote
Post 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:
Image

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.


Mon Jun 14, 2010 1:14 am
Profile
User avatar

Joined: Sun Jul 13, 2008 9:57 am
Posts: 4886
Location: some compy
Reply with quote
Post 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.
I probably would, but I don't have access to CC at the moment so I'm probably only half a useful vote.


Mon Jun 14, 2010 7:19 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.039s | 13 Queries | GZIP : Off ]