无法在VS2010中用lua构建lua项目,怀疑库问题
我正在尝试使用 lua 设置 C++ 控制台应用程序。无论出于何种原因,我无法构建它。我认为 .lib 文件存在问题。
我得到的错误是:
1>------ Build started: Project: testLua, Configuration: Debug Win32 ------
1> testLua.cpp
1>testLua.obj : error LNK2019: unresolved external symbol _luaL_newstate referenced in function _wmain
1>C:\Users\BMillek\Desktop\TestLua\testLua\Debug\testLua.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
这是我在 main 中的内容:
extern "C" {
#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"
}
lua_State* L;
int _tmain(int argc, _TCHAR* argv[])
{
L = lua_open();
while(true)
;
return 0;
}
我自己没有编译 lua。我从 SourceForge 获取了 lua5_1_4_Win64_vc10_lib.zip。 我运行的是 Windows 7,64 位。
对于链接器->输入我有 lua5.1.lib
对于 VC++ 目录 -> 包括我有的目录 C:\Program Files\lua5.1\include
对于VC++参考目录,库目录我有 C:\Program Files\lua5.1
尝试将 .lib 更改为无效的文件名会给我一个错误,所以我假设它正在看到它。
我想我一定缺少一些东西,但我不知道是什么。有什么想法吗?
I'm trying to setup a c++ console application with lua. For whatever reason, I can't get it to build. I think it is some issue with the .lib file.
The error I get is:
1>------ Build started: Project: testLua, Configuration: Debug Win32 ------
1> testLua.cpp
1>testLua.obj : error LNK2019: unresolved external symbol _luaL_newstate referenced in function _wmain
1>C:\Users\BMillek\Desktop\TestLua\testLua\Debug\testLua.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Here is what I have in main:
extern "C" {
#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"
}
lua_State* L;
int _tmain(int argc, _TCHAR* argv[])
{
L = lua_open();
while(true)
;
return 0;
}
I did not compile lua myself. I got lua5_1_4_Win64_vc10_lib.zip off of SourceForge.
I am running Windows 7, 64 bit.
For Linker->Input I have
lua5.1.lib
For VC ++ Directores->Include Directories I have
C:\Program Files\lua5.1\include
For VC ++ Reference Directories, Library Directories I have
C:\Program Files\lua5.1
Trying to change the .lib to a invalid file name gives me a error, so I assume it is seeing it.
I figure there must be something I am missing, but I don't know what. Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当使用 Lua 作为 DLL 时,必须定义
LUA_BUILD_AS_DLL
。这是在配置属性 -> C/C++ -> 预处理器 -> 预处理器定义中完成的。You must define
LUA_BUILD_AS_DLL
when using Lua as a DLL. This is done in Configuration Properties->C/C++->Preprocessor->Preprocessor Defines.