I have Lua 5.1 and Luabind 0.7. I am taking the approach of including the Luabind header files in my project instead of building them as a library/DLL, mainly because I cannot for the love of everything holy figure out exactly how to use Boost-Build to actually build Luabind into something usable.
Anyways, I am using the following code for my application:
/*
Main.cpp
*/
extern "C"
{
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
}
#include <iostream>
#include <luabind/config.hpp>
#include <luabind/class.hpp>
#include <luabind/function.hpp>
#include <luabind/open.hpp>
void greet()
{
std::cout << "Hello World!\n";
}
void main()
{
// Initialize Lua and load default libraries.
lua_State* L = lua_open();
luaL_openlibs(L);
// Initialize Luabind.
luabind::open(L);
// Initialize a Luabind module.
luabind::module(L)
[
luabind::def("Greet", &greet)
];
// Close down Lua.
if (L)
{
lua_close(L);
L = NULL;
}
}
When I compile, I get a massive amount of errors that look like this:
Compiling...
Main.cpp
c:\program files\microsoft visual studio 8\vc\include\xutility(2282) : warning C4996: 'std::_Copy_opt' was declared deprecated
c:\program files\microsoft visual studio 8\vc\include\xutility(2270) : see declaration of 'std::_Copy_opt'
Message: 'You have used a std:: construct that is not safe. See documentation on how to use the Safe Standard C++ Library'
c:\documents and settings\luncih-3\my documents\sdks\luabind\luabind\detail\primitives.hpp(68) : see reference to function template instantiation '_OutIt std::copy<const char*,char*>(_InIt,_InIt,_OutIt)' being compiled
with
[
_OutIt=char *,
_InIt=const char *
]
Compiling manifest to resources...
Linking...
LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
Main.obj : error LNK2019: unresolved external symbol "public: __thiscall luabind::scope::~scope(void)" (??1scope@luabind@@QAE@XZ) referenced in function __unwindfunclet$_main$0
Main.obj : error LNK2019: unresolved external symbol "public: void __thiscall luabind::module_::operator[](struct luabind::scope)" (??Amodule_@luabind@@QAEXUscope@1@@Z) referenced in function _main
Main.obj : error LNK2019: unresolved external symbol "void __cdecl luabind::open(struct lua_State *)" (?open@luabind@@YAXPAUlua_State@@@Z) referenced in function _main
Main.obj : error LNK2019: unresolved external symbol "public: __thiscall luabind::module_::module_(struct lua_State *,char const *)" (??0module_@luabind@@QAE@PAUlua_State@@PBD@Z) referenced in function "class luabind::module_ __cdecl luabind::module(struct lua_State *,char const *)" (?module@luabind@@YA?AVmodule_@1@PAUlua_State@@PBD@Z)
Main.obj : error LNK2019: unresolved external symbol "public: __thiscall luabind::scope::scope(struct luabind::scope const &)" (??0scope@luabind@@QAE@ABU01@@Z) referenced in function "struct luabind::scope __cdecl luabind::def<void (__cdecl*)(void)>(char const *,void (__cdecl*)(void))" (??$def@P6AXXZ@luabind@@YA?AUscope@0@PBDP6AXXZ@Z)
Main.obj : error LNK2019: unresolved external symbol "public: __thiscall luabind::scope::scope(class std::auto_ptr<struct luabind::detail::registration>)" (??0scope@luabind@@QAE@V?$auto_ptr@Uregistration@detail@luabind@@@std@@@Z) referenced in function "struct luabind::scope __cdecl luabind::def<void (__cdecl*)(void)>(char const *,void (__cdecl*)(void))" (??$def@P6AXXZ@luabind@@YA?AUscope@0@PBDP6AXXZ@Z)
Main.obj : error LNK2019: unresolved external symbol "public: __thiscall luabind::detail::registration::registration(void)" (??0registration@detail@luabind@@QAE@XZ) referenced in function "public: __thiscall luabind::detail::function_commiter<void (__cdecl*)(void),struct luabind::detail::null_type>::function_commiter<void (__cdecl*)(void),struct luabind::detail::null_type>(char const *,void (__cdecl*)(void),struct luabind::detail::null_type const &)" (??0?$function_commiter@P6AXXZUnull_type@detail@luabind@@@detail@luabind@@QAE@PBDP6AXXZABUnull_type@12@@Z)
Main.obj : error LNK2019: unresolved external symbol "public: void __thiscall luabind::detail::free_functions::function_rep::add_overload(struct luabind::detail::free_functions::overload_rep const &)" (?add_overload@function_rep@free_functions@detail@luabind@@QAEXABUoverload_rep@234@@Z) referenced in function "public: virtual void __thiscall luabind::detail::function_commiter<void (__cdecl*)(void),struct luabind::detail::null_type>::register_(struct lua_State *)const " (?register_@?$function_commiter@P6AXXZUnull_type@detail@luabind@@@detail@luabind@@UBEXPAUlua_State@@@Z)
Main.obj : error LNK2019: unresolved external symbol "int __cdecl luabind::detail::free_functions::function_dispatcher(struct lua_State *)" (?function_dispatcher@free_functions@detail@luabind@@YAHPAUlua_State@@@Z) referenced in function "public: virtual void __thiscall luabind::detail::function_commiter<void (__cdecl*)(void),struct luabind::detail::null_type>::register_(struct lua_State *)const " (?register_@?$function_commiter@P6AXXZUnull_type@detail@luabind@@@detail@luabind@@UBEXPAUlua_State@@@Z)
Main.obj : error LNK2019: unresolved external symbol "public: static struct luabind::detail::class_registry * __cdecl luabind::detail::class_registry::get_registry(struct lua_State *)" (?get_registry@class_registry@detail@luabind@@SAPAU123@PAUlua_State@@@Z) referenced in function "public: virtual void __thiscall luabind::detail::function_commiter<void (__cdecl*)(void),struct luabind::detail::null_type>::register_(struct lua_State *)const " (?register_@?$function_commiter@P6AXXZUnull_type@detail@luabind@@@detail@luabind@@UBEXPAUlua_State@@@Z)
Main.obj : error LNK2019: unresolved external symbol "int __cdecl luabind::detail::ref(struct lua_State *)" (?ref@detail@luabind@@YAHPAUlua_State@@@Z) referenced in function "public: virtual void __thiscall luabind::detail::function_commiter<void (__cdecl*)(void),struct luabind::detail::null_type>::register_(struct lua_State *)const " (?register_@?$function_commiter@P6AXXZUnull_type@detail@luabind@@@detail@luabind@@UBEXPAUlua_State@@@Z)
Main.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall luabind::detail::registration::~registration(void)" (??1registration@detail@luabind@@UAE@XZ) referenced in function "public: virtual __thiscall luabind::detail::function_commiter<void (__cdecl*)(void),struct luabind::detail::null_type>::~function_commiter<void (__cdecl*)(void),struct luabind::detail::null_type>(void)" (??1?$function_commiter@P6AXXZUnull_type@detail@luabind@@@detail@luabind@@UAE@XZ)
C:\Documents and Settings\luncih-3\My Documents\Visual Studio 2005\Projects\LuaTest\Debug\LuaTest.exe : fatal error LNK1120: 12 unresolved externals
Build log was saved at "file://c:\Documents and Settings\luncih-3\My Documents\Visual Studio 2005\Projects\LuaTest\LuaTest\Debug\BuildLog.htm"
LuaTest - 13 error(s), 2 warning(s)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
What have I missed? I tried looking at the official Luabind guide, some Ogre3D guide and a couple of other (and very similar) guides, but they reveal nothing that I could have missed, except the part where they say it is optional to build Luabind with Boost-Build.