当前位置: 代码迷 >> 其他开发语言 >> vc2008 运行 lua5.1脚本,该怎么解决
  详细解决方案

vc2008 运行 lua5.1脚本,该怎么解决

热度:3625   发布时间:2013-02-26 00:00:00.0
vc2008 运行 lua5.1脚本
#include <stdio.h>

extern "C" {  
#include "lua.h"  
#include "lualib.h"  
#include "lauxlib.h"  
}  
lua_State* L;
int main(void)
{
   
  L = luaL_newstate();
  luaL_openlibs(L);

  luaL_dofile(L,"vs_lua_Test.lua");
  lua_close(L);

  return 0;
}


出现下面这些错误

Win32 ------
1>Compiling...
1>test.cpp
1>Linking...
1>test.obj : error LNK2019: unresolved external symbol "void __cdecl lua_close(struct lua_State *)" (?lua_close@@YAXPAUlua_State@@@Z) referenced in function _main
1>test.obj : error LNK2019: unresolved external symbol "int __cdecl lua_pcall(struct lua_State *,int,int,int)" (?lua_pcall@@YAHPAUlua_State@@HHH@Z) referenced in function _main
1>test.obj : error LNK2019: unresolved external symbol "int __cdecl luaL_loadfile(struct lua_State *,char const *)" (?luaL_loadfile@@YAHPAUlua_State@@PBD@Z) referenced in function _main
1>test.obj : error LNK2019: unresolved external symbol "void __cdecl luaL_openlibs(struct lua_State *)" (?luaL_openlibs@@YAXPAUlua_State@@@Z) referenced in function _main
1>test.obj : error LNK2019: unresolved external symbol "struct lua_State * __cdecl luaL_newstate(void)" (?luaL_newstate@@YAPAUlua_State@@XZ) referenced in function _ma

搞了很久,搞不定,能告诉咋搞吗?


------解决方案--------------------------------------------------------
#include "luaconf.h" //这个很关键
#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"


------解决方案--------------------------------------------------------
还要连接相关的库
lua51.lib