晨旭的博客
你想干什么!
晨旭的博客~
使用 Visual Studio 2017 编译 Lua 源码

首先去官网下载源码:

https://www.lua.org

https://source.papapoi.com/wp-content/uploads/2018/12/f164b900f290ddac122afc363848f460.png?imageView2/2/w/800|watermark/1/image/aHR0cDovL3NvdXJjZS5wYXBhcG9pLmNvbS93cC1jb250ZW50L3VwbG9hZHMvMjAxNi8wOC9sb2dvcGljLnBuZw==/dissolve/100/gravity/SouthEast/dx/10/dy/10

https://source.papapoi.com/wp-content/uploads/2018/12/9d2d209e84c94ee1b15dd34c28ecd8b0.png?imageView2/2/w/800|watermark/1/image/aHR0cDovL3NvdXJjZS5wYXBhcG9pLmNvbS93cC1jb250ZW50L3VwbG9hZHMvMjAxNi8wOC9sb2dvcGljLnBuZw==/dissolve/100/gravity/SouthEast/dx/10/dy/10

接着打开vs,如果你没装c/c++部分,需要补充安装:

https://source.papapoi.com/wp-content/uploads/2018/12/d1c07c69c84625ea84cd59b9db9fbc33.png?imageView2/2/w/800|watermark/1/image/aHR0cDovL3NvdXJjZS5wYXBhcG9pLmNvbS93cC1jb250ZW50L3VwbG9hZHMvMjAxNi8wOC9sb2dvcGljLnBuZw==/dissolve/100/gravity/SouthEast/dx/10/dy/10

https://source.papapoi.com/wp-content/uploads/2018/12/4831c7597464a7276effd32cf2baeda4.png?imageView2/2/w/800|watermark/1/image/aHR0cDovL3NvdXJjZS5wYXBhcG9pLmNvbS93cC1jb250ZW50L3VwbG9hZHMvMjAxNi8wOC9sb2dvcGljLnBuZw==/dissolve/100/gravity/SouthEast/dx/10/dy/10

安装完后,新建一个空的工程:

https://source.papapoi.com/wp-content/uploads/2018/12/20905b93f7adba936ab28f6f86aa5662.png?imageView2/2/w/800|watermark/1/image/aHR0cDovL3NvdXJjZS5wYXBhcG9pLmNvbS93cC1jb250ZW50L3VwbG9hZHMvMjAxNi8wOC9sb2dvcGljLnBuZw==/dissolve/100/gravity/SouthEast/dx/10/dy/10

将下好的源码拖入刚刚新建的工程文件夹:

https://source.papapoi.com/wp-content/uploads/2018/12/20158871ae01771904ecc0ae18f46164.png?imageView2/2/w/800|watermark/1/image/aHR0cDovL3NvdXJjZS5wYXBhcG9pLmNvbS93cC1jb250ZW50L3VwbG9hZHMvMjAxNi8wOC9sb2dvcGljLnBuZw==/dissolve/100/gravity/SouthEast/dx/10/dy/10

https://source.papapoi.com/wp-content/uploads/2018/12/1ebda0c42011dda5a7bfd2bb150d085c.png?imageView2/2/w/800|watermark/1/image/aHR0cDovL3NvdXJjZS5wYXBhcG9pLmNvbS93cC1jb250ZW50L3VwbG9hZHMvMjAxNi8wOC9sb2dvcGljLnBuZw==/dissolve/100/gravity/SouthEast/dx/10/dy/10

右击解决方案资源管理器空白处,新建一个项目:

https://source.papapoi.com/wp-content/uploads/2018/12/ec212321e6369392ea93a86ccc479b2a.png?imageView2/2/w/800|watermark/1/image/aHR0cDovL3NvdXJjZS5wYXBhcG9pLmNvbS93cC1jb250ZW50L3VwbG9hZHMvMjAxNi8wOC9sb2dvcGljLnBuZw==/dissolve/100/gravity/SouthEast/dx/10/dy/10

选择静态库,命名为lualib

https://source.papapoi.com/wp-content/uploads/2018/12/fbc8a882345c8ef5bb698ba91964cc2f.png?imageView2/2/w/800|watermark/1/image/aHR0cDovL3NvdXJjZS5wYXBhcG9pLmNvbS93cC1jb250ZW50L3VwbG9hZHMvMjAxNi8wOC9sb2dvcGljLnBuZw==/dissolve/100/gravity/SouthEast/dx/10/dy/10

右击新建的项目,添加现有文件:

https://source.papapoi.com/wp-content/uploads/2018/12/4fe212abed1bc378da49e96e6e0bddd2.png?imageView2/2/w/800|watermark/1/image/aHR0cDovL3NvdXJjZS5wYXBhcG9pLmNvbS93cC1jb250ZW50L3VwbG9hZHMvMjAxNi8wOC9sb2dvcGljLnBuZw==/dissolve/100/gravity/SouthEast/dx/10/dy/10

选中除了lua.cluac.c外的所有c文件,回车:

https://source.papapoi.com/wp-content/uploads/2018/12/91edcc107234398976b38fc06830fdd4.png?imageView2/2/w/800|watermark/1/image/aHR0cDovL3NvdXJjZS5wYXBhcG9pLmNvbS93cC1jb250ZW50L3VwbG9hZHMvMjAxNi8wOC9sb2dvcGljLnBuZw==/dissolve/100/gravity/SouthEast/dx/10/dy/10

右击lualib,点属性:

https://source.papapoi.com/wp-content/uploads/2018/12/d986b00e4db52bcdd83a9634f533bd57.png?imageView2/2/w/800|watermark/1/image/aHR0cDovL3NvdXJjZS5wYXBhcG9pLmNvbS93cC1jb250ZW50L3VwbG9hZHMvMjAxNi8wOC9sb2dvcGljLnBuZw==/dissolve/100/gravity/SouthEast/dx/10/dy/10

改为从不使用预编译头:

https://source.papapoi.com/wp-content/uploads/2018/12/8de951c6421414dcf5b4982772902a1a.png?imageView2/2/w/800|watermark/1/image/aHR0cDovL3NvdXJjZS5wYXBhcG9pLmNvbS93cC1jb250ZW50L3VwbG9hZHMvMjAxNi8wOC9sb2dvcGljLnBuZw==/dissolve/100/gravity/SouthEast/dx/10/dy/10

复制输出目录$(SolutionDir)$(Configuration)\,后面会用到:

https://source.papapoi.com/wp-content/uploads/2018/12/295cc4e0fc21d5e198aff0f27a8e9491.png?imageView2/2/w/800|watermark/1/image/aHR0cDovL3NvdXJjZS5wYXBhcG9pLmNvbS93cC1jb250ZW50L3VwbG9hZHMvMjAxNi8wOC9sb2dvcGljLnBuZw==/dissolve/100/gravity/SouthEast/dx/10/dy/10

右击项目,点生成:

https://source.papapoi.com/wp-content/uploads/2018/12/068308e6f569a497516d1b02af5e48d5.png?imageView2/2/w/800|watermark/1/image/aHR0cDovL3NvdXJjZS5wYXBhcG9pLmNvbS93cC1jb250ZW50L3VwbG9hZHMvMjAxNi8wOC9sb2dvcGljLnBuZw==/dissolve/100/gravity/SouthEast/dx/10/dy/10

https://source.papapoi.com/wp-content/uploads/2018/12/9a9f694e0421a9fa572a9e97227de077.png?imageView2/2/w/800|watermark/1/image/aHR0cDovL3NvdXJjZS5wYXBhcG9pLmNvbS93cC1jb250ZW50L3VwbG9hZHMvMjAxNi8wOC9sb2dvcGljLnBuZw==/dissolve/100/gravity/SouthEast/dx/10/dy/10

再添加一个项目:

https://source.papapoi.com/wp-content/uploads/2018/12/0c97ad8139334639bff4bf7c5383b075.png?imageView2/2/w/800|watermark/1/image/aHR0cDovL3NvdXJjZS5wYXBhcG9pLmNvbS93cC1jb250ZW50L3VwbG9hZHMvMjAxNi8wOC9sb2dvcGljLnBuZw==/dissolve/100/gravity/SouthEast/dx/10/dy/10

选择控制台程序,命名为lua:

https://source.papapoi.com/wp-content/uploads/2018/12/1d842b7856ea16a662d2898f68193f6e.png?imageView2/2/w/800|watermark/1/image/aHR0cDovL3NvdXJjZS5wYXBhcG9pLmNvbS93cC1jb250ZW50L3VwbG9hZHMvMjAxNi8wOC9sb2dvcGljLnBuZw==/dissolve/100/gravity/SouthEast/dx/10/dy/10

和之前一样,只添加lua.clua.h到此工程,同时删掉lua.cpp

https://source.papapoi.com/wp-content/uploads/2018/12/7847143f757e97275d625a6bcbe7c524.png?imageView2/2/w/800|watermark/1/image/aHR0cDovL3NvdXJjZS5wYXBhcG9pLmNvbS93cC1jb250ZW50L3VwbG9hZHMvMjAxNi8wOC9sb2dvcGljLnBuZw==/dissolve/100/gravity/SouthEast/dx/10/dy/10

https://source.papapoi.com/wp-content/uploads/2018/12/ae1aa22401a67a44f9cffa6e8595e407.png?imageView2/2/w/800|watermark/1/image/aHR0cDovL3NvdXJjZS5wYXBhcG9pLmNvbS93cC1jb250ZW50L3VwbG9hZHMvMjAxNi8wOC9sb2dvcGljLnBuZw==/dissolve/100/gravity/SouthEast/dx/10/dy/10

同样右击lua项目,点属性,关闭预编译头:

https://source.papapoi.com/wp-content/uploads/2018/12/e84d7f6bb6a78ccc1212a7a2947ca67a.png?imageView2/2/w/800|watermark/1/image/aHR0cDovL3NvdXJjZS5wYXBhcG9pLmNvbS93cC1jb250ZW50L3VwbG9hZHMvMjAxNi8wOC9sb2dvcGljLnBuZw==/dissolve/100/gravity/SouthEast/dx/10/dy/10

将刚刚复制的路径$(SolutionDir)$(Configuration)\放到链接器-常规-附加库目录:

https://source.papapoi.com/wp-content/uploads/2018/12/204f9cbaf2fe18f002b60b1a622c2632.png?imageView2/2/w/800|watermark/1/image/aHR0cDovL3NvdXJjZS5wYXBhcG9pLmNvbS93cC1jb250ZW50L3VwbG9hZHMvMjAxNi8wOC9sb2dvcGljLnBuZw==/dissolve/100/gravity/SouthEast/dx/10/dy/10

编辑链接器-输入-附加依赖项:

https://source.papapoi.com/wp-content/uploads/2018/12/941352626a32343712aecad0b72f796c.png?imageView2/2/w/800|watermark/1/image/aHR0cDovL3NvdXJjZS5wYXBhcG9pLmNvbS93cC1jb250ZW50L3VwbG9hZHMvMjAxNi8wOC9sb2dvcGljLnBuZw==/dissolve/100/gravity/SouthEast/dx/10/dy/10

输入lualib.lib,确认保存:

https://source.papapoi.com/wp-content/uploads/2018/12/0dcbad6d2ce716ff6df6c38642c72bff.png?imageView2/2/w/800|watermark/1/image/aHR0cDovL3NvdXJjZS5wYXBhcG9pLmNvbS93cC1jb250ZW50L3VwbG9hZHMvMjAxNi8wOC9sb2dvcGljLnBuZw==/dissolve/100/gravity/SouthEast/dx/10/dy/10

右击项目,生成:

https://source.papapoi.com/wp-content/uploads/2018/12/b14f02ce5848fbdd5564275efb737338.png?imageView2/2/w/800|watermark/1/image/aHR0cDovL3NvdXJjZS5wYXBhcG9pLmNvbS93cC1jb250ZW50L3VwbG9hZHMvMjAxNi8wOC9sb2dvcGljLnBuZw==/dissolve/100/gravity/SouthEast/dx/10/dy/10

https://source.papapoi.com/wp-content/uploads/2018/12/565d9242021f9be9a9764e7094c1779b.png?imageView2/2/w/800|watermark/1/image/aHR0cDovL3NvdXJjZS5wYXBhcG9pLmNvbS93cC1jb250ZW50L3VwbG9hZHMvMjAxNi8wOC9sb2dvcGljLnBuZw==/dissolve/100/gravity/SouthEast/dx/10/dy/10

生成成功:

https://source.papapoi.com/wp-content/uploads/2018/12/ce237db3bcb7fbff0c6ff284cf0dc8c3.png?imageView2/2/w/800|watermark/1/image/aHR0cDovL3NvdXJjZS5wYXBhcG9pLmNvbS93cC1jb250ZW50L3VwbG9hZHMvMjAxNi8wOC9sb2dvcGljLnBuZw==/dissolve/100/gravity/SouthEast/dx/10/dy/10

赞赏
如非特殊说明,本站所有文章均采用知识共享 署名-非商业性使用-相同方式共享4.0国际许可协议(CC BY-NC-SA 4.0)进行许可。

发表评论

textsms
account_circle
email

  • https://secure.gravatar.com/avatar/4d9dc6065fd8bfbc422de283d3bb67da?s=80&d=mm&r=x
    沙缸过滤器
    Google Chrome 69.0.3497.92 Google Chrome 69.0.3497.92 Windows 7 x64 Edition Windows 7 x64 Edition
    Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.92 Safari/537.36

    说的很详细

    4天前回复
  • https://secure.gravatar.com/avatar/1b15c6bc386186ac7c55f59b14b4418f?s=80&d=mm&r=x
    Pt
    Google Chrome 71.0.3578.80 Google Chrome 71.0.3578.80 Windows 10 x64 Edition Windows 10 x64 Edition
    Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.80 Safari/537.36

    apt install lua5.3

    2天前回复

晨旭的博客~

使用 Visual Studio 2017 编译 Lua 源码
首先去官网下载源码: https://www.lua.org 接着打开vs,如果你没装c/c++部分,需要补充安装: 安装完后,新建一个空的工程: 将下好的源码拖入刚刚新建的工程文件夹: …
扫描二维码继续阅读
2018-12-04