user873400
user873400

Reputation: 11

Can't build lua a project with lua in VS2010, library issue suspected

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?

Upvotes: 1

Views: 872

Answers (1)

Nicol Bolas
Nicol Bolas

Reputation: 473847

You must define LUA_BUILD_AS_DLL when using Lua as a DLL. This is done in Configuration Properties->C/C++->Preprocessor->Preprocessor Defines.

Upvotes: 1

Related Questions