如何链接Lua在Microsoft Visual C ++。2010 Express? [英] How to link Lua in Microsoft Visual C++.2010 Express?

查看:150
本文介绍了如何链接Lua在Microsoft Visual C ++。2010 Express?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图编写可以从Lua访问的C ++类/函数。

I am trying to write C++ classes/functions which can be accessed from Lua.

我需要将C ++库导出为dll文件。

I need to export the C++ library as dll files.

我使用Microsoft Visual C ++ 2010 Express

I'm using Microsoft Visual C++.2010 Express

所以我创建一个项目并添加require .cpp文件和.h文件
现在当我尝试构建,发生以下错误。

So I create a project and add the require .cpp files and .h files Now when I try to build, the following error occurs.


mylib.obj:error LNK2019:unresolved external symbol _lua_settop
在函数void __cdecl g_initializePlugin(struct
lua_State *)(?g_initializePlugin @@ YAXPAUlua_State @@@ Z)中引用

mylib.obj : error LNK2019: unresolved external symbol _lua_settop referenced in function "void __cdecl g_initializePlugin(struct lua_State *)" (?g_initializePlugin@@YAXPAUlua_State@@@Z)

所有lua函数都会出现类似的错误。当Google搜索时,我发现我必须链接LUA。

Similar errors occur for all lua functions. When Googling I learnt that I had to link LUA.

如何在Visual C ++中完成。

How can that be done in Visual C++.

PS
我找到一个解决方案,指示我提供

P.S I found a solution which directed me to give

#pragma comment( lib, "lua5.1" ) 

lua5.1文件。

For this solution, it requires a lua5.1 file. From where should I download that file and where should it go (in the project folder?) ?

推荐答案

确定!我应该从哪里下载该文件?我想出了怎么样!

OK! I figured out how!

要链接Lua,必须在C ++项目创建后进行以下操作。

To link Lua, the following has to be done after the C++ project has been created.


  • 将C:\Program Files\Lua\5.1\lib\lua5.1.dll复制到您的项目文件夹

  • 复制C:\Program文件\Lua\5.1\lib\lua5.1.lib到您的项目文件夹

  • 右键单击项目 - >属性 - >配置属性
    - >链接器 - >输入。

    • 将lua5.1.lib添加到其他依赖关系


    • 添加C:\Program Files\Lua\5.1\\ \\ include>

    注意:我的lua安装位于C:\\ \\ Program文件\Lua\5.1

    NOTE : my lua installation is in C:\Program Files\Lua\5.1

    现在建立项目时,会创建dll文件!

    Now on building the project, dll file is created!

    这篇关于如何链接Lua在Microsoft Visual C ++。2010 Express?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆