Jump to content
  • 0

[C++]Sharing libraries, LUA functions


stefano9876

Question

GoodDay M2D.

I've compiled successfully a .cpp file using G++ in VirtualBox.

But when i've tried to call one function it return an error.

 

 

src.cpp

#include "./src/lua.h"
#include "./src/stdafx.h"
#include <sstream>
#include "./src/constants.h"
#include "./src/questmanager.h"
#include "./src/questlua.h"
#include "./src/questevent.h"

namespace quest
{
	int _ciao_mondo(lua_State* L)
	{
		ostringstream s;
		combine_lua_string(L, s);
		CQuestManager::Instance().AddScript(s.str());
		return 0;
	}
	
	void RegisterGlobalFunctionTable(lua_State* L)
	{
		extern int quest_setstate(lua_State* L);

		luaL_reg global_functions[] =
		{
			{	"ciao_mondo",_ciao_mondo	},
			{	NULL,	NULL	}
		};
	
		int i = 0;

		while (global_functions[i].name != NULL)
		{
			lua_register(L, global_functions[i].name, global_functions[i].func);
			++i;
		}
	}
} 

quest used to call the function

quest prova begin
 state start begin
  when 9006.chat."LIBRARY TEST" with pc.is_gm() begin
   ciao_mondo("TEST-> ")
  end
 end
end

LUA error

Link -> http://puu.sh/a84jk/54b3ac6df6.jpg

 

Code used to load the library:

env LD_32_PRELOAD="/usr/home/game/libs/libfoo.so"

Code used to compile the library:

g++ foo.cpp -o libfoo.so -shared -fPIC

Thx!

Link to comment
  • Answers 6
  • Created
  • Last Reply

Top Posters For This Question

Popular Days

Top Posters For This Question

6 answers to this question

Recommended Posts

  • 0

I don't know Q_Q

Maybe the sources found on RaGEZONE?

 

Someone did that and share on epvp and other forums.

 

Best Regards

Ellie

Do not be sorry, be better.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.