Hi, I've wasted the entire day trying to get the Lua library lua52.lib linked to my C++ project in Code Blocks.
I'm at a loss as to what is wrong. I have the .lib file in C:\MinGW\lib. I have the header cLua.h in C:\MinGW\include.
The .lib file is specified in the Link Libraries list in Build options. I (of course) #include "cLua.h" in my project.
The directories for library and include are specified in "Search Directories" for the compiler.
Whenever I try to create a new instance of the cLua class from cLua.h
the following error appears during the linking stage:
undefined reference to `cLua::cLua()'
I'm trying to figure out what I've overlooked here. This library just refuses to link no matter what. Please help. Going insane here :P
Edit: I should note that other libraries such as SDL have linked just fine.
Yeah this may be more a Lua issue. But im really not sure.
At this point I've tried just about everything. I even built Lua from source with the proper mingw commands in the make file. same thing.
I'm using the header file cLua.h. This inits Lua. Could this be the problem?
Is there a definitive way to test and see if a library is linking properly?
cLua.h:
#ifndef __CLUA__
#define __CLUA__
struct lua_State;
#define LuaGlue extern "C" int
extern "C" {
typedef int (*LuaFunctionType)(struct lua_State *pLuaState);
};
class cLua
{
public:
cLua();
virtual ~cLua();
bool RunScript(const char *pFilename);
bool RunString(const char *pCommand);
const char *GetErrorString(void);
bool AddFunction(const char *pFunctionName, LuaFunctionType pFunction);
const char *GetStringArgument(int num, const char *pDefault=NULL);
double GetNumberArgument(int num, double dDefault=0.0);
void PushString(const char *pString);
void PushNumber(double value);
void SetErrorHandler(void(*pErrHandler)(const char *pError)) {m_pErrorHandler = pErrHandler;}
lua_State *GetScriptContext(void) {return m_pScriptContext;}
private:
lua_State *m_pScriptContext;
void(*m_pErrorHandler)(const char *pError);
};
#endif