title: Having trouble embedding Lua for Windows install into C++ program
body: <p>This is the first question I have found myself not being able to get to the bottom of using my normal googling/stack overflowing/youtubing routine.</p>
  
  <p>I am trying to compile a minimal Lua program inside of a C++ environment just to ensure my environment is ready to development. The Lua language will be later used for User Interface programming for my C++ game.</p>
  
  <h1>First some basic information on my environment:</h1>
  
  <p>Windows 7 64-bit</p>
  
  <p>Visual studio 2010</p>
  
  <p>Lua for Windows 5.1 (latest build I could download from google code)</p>
  
  <h1>Here is the code I am trying to compile:</h1>
  
  <pre><code>// UserInt.cpp : Defines the entry point for the console application.
  //
  #pragma comment(lib,"lua5.1.dll")
  #include "stdafx.h"
  #ifndef __LUA_INC_H__
  #define __LUA_INC_H__
  
  extern "C"
  {
     #include "lua.h"
     #include "lauxlib.h"
     #include "lualib.h"
  }
  
  
  
  int _tmain(int argc, _TCHAR* argv[])
  {
      lua_State * ls = luaL_newstate();
      return 0;
  }
  
  #endif // __LUA_INC_H__
  </code></pre>
  
  <h1>Here is the Error I am getting:</h1>
  
  <p><code>1&gt;UserInt.obj : error LNK2019: unresolved external symbol _luaL_newstate referenced in                                                     function _wmain
  1&gt;c:\users\deank\documents\visual studio 2010\Projects\UserInt\Debug\UserInt.exe : fatal error LNK1120: 1 unresolved externals</code></p>
  
  <h1>Things I have tried:</h1>
  
  <p>I have read about lua_open()(and several other functions) no longer being used so I tried the newstate function instead. I get the same error. This was more of a sanity check than anything. I am using 5.1 and not 5.2 so I do not think this really matters.</p>
  
  <p>I have also read this thread <a href="https://stackoverflow.com/questions/4150081/cannot-link-a-minimal-lua-program">Cannot link a minimal Lua program</a> but it does not seem to help me because I am not running the same environment as that OP. I am on a simple windows 7 and visual studio environment.</p>
  
  <p>The top pragma comment line was something I saw in yet another thread. I get the same error with or without it.</p>
  
  <p>I have gone into my visual studio C++ directories area and added the lua include to the includes and the lua lib to the libraries. </p>
  
  <p>So it seems like my program is seeing the .h and seeing the symbol. But for some reason it is not getting the .cpp implementation for the functions. This is why I was hoping including that .dll directly would help fix the problem, but it hasn't.</p>
  
  <p>So, I feel like I have exhausted all of my options solving this on my own. I hope someone is able to help me move forward here. Lua looks like an awesome language to script in and I would like to get my environment squared away for development.</p>
  
  <p>I hope it is just some silly error on my part. I believe I have provided as much information as I can. If you need more specifics I will update with info if I can provide it.</p>
  
  <h1>Edit1</h1>
  
  <p>Tried the solution in this <a href="https://stackoverflow.com/questions/6903698/cant-build-lua-a-project-with-lua-in-vs2010-library-issue-suspected?rq=1">Can&#39;t build lua a project with lua in VS2010, library issue suspected</a> </p>
  
  <p>That did not work either.</p>