简体   繁体   English

如何静态构建和链接LuaJIT(VS 2013)

[英]How to build and link LuaJIT statically (VS 2013)

Premise : I'd like my C++ application not to depend on whatever Microsoft Visual C++ redistributable , so I can ship my executable file that will work out of the box. 前提:我希望我的C ++应用程序不依赖于任何Microsoft Visual C++ redistributable ,因此我可以提供开箱即用的可执行文件。

What I've done first : switching the runtime library to Multithread (/MT) from DLL Multithread (/MD) in order to avoid the need for msvcr110.dll (and shouldn't VS 2013 require the 120 version, as it's the compiler version ?). 我先做了什么:从DLL Multithread (/MD)切换运行时库到Multithread (/MT)以避免需要msvcr110.dll (并且不应该VS 2013需要120版本,因为它是编译器版本?)。 To do that I also had to recompile another library I'm using with the same runtime library, and that worked. 为此,我还必须使用相同的运行时库重新编译我正在使用的另一个库,这样才有效。 I had my .exe which could be ran anywhere without problems (or I wasn't aware of, haha). 我的.exe可以在任何地方运行而没有问题(或者我不知道,哈哈)。

Then I added some functionalities that make use of LuaJIT. 然后我添加了一些使用LuaJIT的功能。 I've built LuaJIT by the msvcbuild.bat provided with the package and it worked like a charm, but now my executable requires the msvcr110.dll to run. 我已经通过随包提供的msvcbuild.bat构建了msvcbuild.bat ,它就像一个魅力,但现在我的可执行文件需要运行msvcr110.dll I guess that's because LuaJIT was compiled with the /MD flag, but I'd like to know if there is a proper way to do what I want. 我想这是因为LuaJIT是用/ MD标志编译的,但我想知道是否有一种正确的方法来做我想要的。

您应该使用静态命令行参数运行msvcbuild.bat

I didn't test this, but you most likely need to use the /MT flag on each piece of the compilation you do. 我没有对此进行测试,但您很可能需要在编译的每个部分上使用/ MT标志。 In this case, both your main program, and LuaJIT. 在这种情况下,你的主程序和LuaJIT。 In that msvcbuild.bat file ( https://github.com/luvit/luajit-2.0/blob/master/src/msvcbuild.bat ) you can see that they are explicitly specifying /MD (line 17). 在那个msvcbuild.bat文件( https://github.com/luvit/luajit-2.0/blob/master/src/msvcbuild.bat )中,您可以看到它们是明确指定/ MD(第17行)。 Methinks that is your problem. Methinks是你的问题。 Change it to /MT and see. 将其更改为/ MT并查看。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM