level 1
1、创建一个Visual C++的Empty Project,如果需要支持Windows XP将Platform Toolset设置为Visual Studio 2013 - Windows XP (v120_xp)。
2、Configuration Type设置为Dynamic Library (.dll)。
3、添加对应的源代码文件,但lua.c、luac.c文件除外。
4、C/C++ -> Command Line的Additional Options添加/D _CRT_SECURE_NO_WARNINGS。
5、查看luaconf.h,如果需要导出函数:C/C++ -> Preprocessor添加一个LUA_BUILD_AS_DLL。
6、编译源代码。
2015年08月08日 12点08分
1
level 1
本人使用VS2012按照上述教程编译Lua5.3.1源码。能够生成DLL以及lib文件。但在test项目中出现如下问题
>test.obj : error LNK2019: 无法解析的外部符号 "__dec
lsp
ec(dllimport) void __cdecl lua_close(struct lua_State *)" (__imp_?lua_close@@YAXPAUlua_State@@@Z),该符号在函数 _main 中被引用
1>test.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) int __cdecl lua_pcallk(struct lua_State *,int,int,int,int,int (__cdecl*)(struct lua_State *,int,int))" (__imp_?lua_pcallk@@YAHPAUlua_State@@HHHHP6AH0HH@Z@Z),该符号在函数 _main 中被引用
1>test.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) void __cdecl luaL_openlibs(struct lua_State *)" (__imp_?luaL_openlibs@@YAXPAUlua_State@@@Z),该符号在函数 _main 中被引用
1>test.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) int __cdecl luaL_loadfilex(struct lua_State *,char const *,char const *)" (__imp_?luaL_loadfilex@@YAHPAUlua_State@@PBD1@Z),该符号在函数 _main 中被引用
1>test.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) struct lua_State * __cdecl luaL_newstate(void)" (__imp_?luaL_newstate@@YAPAUlua_State@@XZ),该符号在函数 _main 中被引用
1>E:\Project\Lua\Debug\test.exe : fatal error LNK1120: 5 个无法解析的外部命令
2015年08月08日 12点08分
2