Jump to content
  • Advertisement
Sign in to follow this  
Plasmarobo

ToLua++

This topic is 3735 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey, is anyone familiar with ToLua++? I'm attempting to use it to bind my code to Lua, but the generated code contains a myriad of linker errors. The nasty External Symbol kind too. I'm still stumbling my way through this system. Anyway, I'd like to know how to fix these, or at least what the cause is. I'm betting I forgot to include some file, or link to a library.
Bindings.obj : error LNK2019: unresolved external symbol _tolua_endmodule referenced in function "int __cdecl tolua__open(struct lua_State *)" (?tolua__open@@YAHPAUlua_State@@@Z)
Bindings.obj : error LNK2019: unresolved external symbol _tolua_function referenced in function "int __cdecl tolua__open(struct lua_State *)" (?tolua__open@@YAHPAUlua_State@@@Z)
Bindings.obj : error LNK2019: unresolved external symbol _tolua_cclass referenced in function "int __cdecl tolua__open(struct lua_State *)" (?tolua__open@@YAHPAUlua_State@@@Z)
Bindings.obj : error LNK2019: unresolved external symbol _tolua_beginmodule referenced in function "int __cdecl tolua__open(struct lua_State *)" (?tolua__open@@YAHPAUlua_State@@@Z)
Bindings.obj : error LNK2019: unresolved external symbol _tolua_module referenced in function "int __cdecl tolua__open(struct lua_State *)" (?tolua__open@@YAHPAUlua_State@@@Z)
Bindings.obj : error LNK2019: unresolved external symbol _tolua_open referenced in function "int __cdecl tolua__open(struct lua_State *)" (?tolua__open@@YAHPAUlua_State@@@Z)
Bindings.obj : error LNK2019: unresolved external symbol _tolua_tousertype referenced in function "int __cdecl tolua_collect_Base__Character(struct lua_State *)" (?tolua_collect_Base__Character@@YAHPAUlua_State@@@Z)
Bindings.obj : error LNK2019: unresolved external symbol _tolua_usertype referenced in function "void __cdecl tolua_reg_types(struct lua_State *)" (?tolua_reg_types@@YAXPAUlua_State@@@Z)
Bindings.obj : error LNK2019: unresolved external symbol _tolua_error referenced in function "int __cdecl tolua__Base_Item_new00(struct lua_State *)" (?tolua__Base_Item_new00@@YAHPAUlua_State@@@Z)
Bindings.obj : error LNK2019: unresolved external symbol _tolua_pushusertype referenced in function "int __cdecl tolua__Base_Item_new00(struct lua_State *)" (?tolua__Base_Item_new00@@YAHPAUlua_State@@@Z)
Bindings.obj : error LNK2019: unresolved external symbol _tolua_isnoobj referenced in function "int __cdecl tolua__Base_Item_new00(struct lua_State *)" (?tolua__Base_Item_new00@@YAHPAUlua_State@@@Z)
Bindings.obj : error LNK2019: unresolved external symbol _tolua_isusertable referenced in function "int __cdecl tolua__Base_Item_new00(struct lua_State *)" (?tolua__Base_Item_new00@@YAHPAUlua_State@@@Z)
Bindings.obj : error LNK2019: unresolved external symbol _tolua_pushusertype_and_takeownership referenced in function "int __cdecl tolua__Base_Item_new00_local(struct lua_State *)" (?tolua__Base_Item_new00_local@@YAHPAUlua_State@@@Z)
Bindings.obj : error LNK2019: unresolved external symbol _tolua_isusertype referenced in function "int __cdecl tolua__Base_Item_new01(struct lua_State *)" (?tolua__Base_Item_new01@@YAHPAUlua_State@@@Z)
Bindings.obj : error LNK2019: unresolved external symbol _tolua_pushnumber referenced in function "int __cdecl tolua__Base_Item_GetWeight00(struct lua_State *)" (?tolua__Base_Item_GetWeight00@@YAHPAUlua_State@@@Z)
Bindings.obj : error LNK2019: unresolved external symbol _tolua_pushstring referenced in function "int __cdecl tolua__Base_Item_GetScript00(struct lua_State *)" (?tolua__Base_Item_GetScript00@@YAHPAUlua_State@@@Z)
Bindings.obj : error LNK2019: unresolved external symbol _tolua_isstring referenced in function "int __cdecl tolua__Base_Item_SetScript00(struct lua_State *)" (?tolua__Base_Item_SetScript00@@YAHPAUlua_State@@@Z)
Bindings.obj : error LNK2019: unresolved external symbol _tolua_tostring referenced in function _tolua_tocppstring
Bindings.obj : error LNK2019: unresolved external symbol _tolua_tonumber referenced in function "int __cdecl tolua__Base_Spell_SetCost00(struct lua_State *)" (?tolua__Base_Spell_SetCost00@@YAHPAUlua_State@@@Z)
Bindings.obj : error LNK2019: unresolved external symbol _tolua_isnumber referenced in function "int __cdecl tolua__Base_Spell_SetCost00(struct lua_State *)" (?tolua__Base_Spell_SetCost00@@YAHPAUlua_State@@@Z)
.\Debug\WinCons.exe : fatal error LNK1120: 20 unresolved externals

It looks to me like I need to include ToLua.h or something like that... what say you?

Share this post


Link to post
Share on other sites
Advertisement
Quote:
It looks to me like I need to include ToLua.h or something like that... what say you?
No, because you have a linker error. Your files compiled fine, but in the linking stage, some of the code was missing (the tolua code). Did you indicate the location of the library in your IDE project settings, or when calling the compiler?

Share this post


Link to post
Share on other sites
This should be moved to Scripting Languages and Game Mods I believe.

Yes, you need to link tolua's .lib file to your project to get rid of these linker errors, I had the same issue with luabind but I got it working.

[Edited by - Tenac on July 31, 2008 3:48:55 PM]

Share this post


Link to post
Share on other sites
Well, I would say that there is ambiguity, since I'm new at this the beginners forum seemed the way to go (also the scripting forum is dead).
Anyway, I fixed this by building the tolua library, and linking to that and the lua libraries... but now I have a different question, namely:
How do I move things out of Lua and into C++?

I move them into Lua by using the tolua_pushuserdata function,
and at the moment I am removing them with a nice lua_touserdata and a type cast... since Lua returns a pointer, I am worried about memory scoping, garbage collection, etc.

Should I just make a deep copy of the data (cast the pointer, then copy the memory?)
or what?

Share this post


Link to post
Share on other sites
Quote:
Original post by Plasmarobo

I move them into Lua by using the tolua_pushuserdata function,
and at the moment I am removing them with a nice lua_touserdata and a type cast... since Lua returns a pointer, I am worried about memory scoping, garbage collection, etc.

Should I just make a deep copy of the data (cast the pointer, then copy the memory?)
or what?


This topic is extensively covered in one of Game Programming Gems series (4, I think).

Since Lua has garbage collection, you need to be clear on ownership, and where copy semantics are appropriate.

Unfortunately it's been a while since I was dealing with that, so I don't remember exactly how I solved it. Just be clear on who owns the individual values, and that decides whether to copy/convert data or now.

The pointers you deal with with user types have various meta data associated with them, that can be helpful as well.

Google around a bit on how to pass custom types between the two, there used to be several tutorials showing how to do these conversions.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!