在VS2010中无法使用lua构建lua项目,怀疑是库问题 [英] Can't build lua a project with lua in VS2010, library issue suspected
问题描述
我正在尝试使用lua设置c ++控制台应用程序.无论出于什么原因,我都无法构建它.我认为.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.
我得到的错误是:
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 ==========
这是我的主要内容:
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位).
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.
对于链接器->输入,我有 lua5.1.lib
For Linker->Input I have lua5.1.lib
对于VC ++ Directores->包括我拥有的目录 C:\ Program Files \ lua5.1 \ include
For VC ++ Directores->Include Directories I have C:\Program Files\lua5.1\include
对于VC ++参考目录,我拥有的库目录 C:\ Program Files \ lua5.1
For VC ++ Reference Directories, Library Directories I have C:\Program Files\lua5.1
尝试将.lib更改为无效的文件名会给我一个错误,因此我认为它可以看到它.
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?
推荐答案
在将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.
这篇关于在VS2010中无法使用lua构建lua项目,怀疑是库问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!