Reputation: 1460
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.
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 ?). 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).
Then I added some functionalities that make use of 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. 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.
Upvotes: 3
Views: 6368
Reputation: 145
LuaJIT Makefile says:
# Mixed mode is not supported on Windows. And static mode doesn't work well.
# C modules cannot be loaded, because they bind to lua51.dll.
I'm not a Windows user and don't have a working version installed so I can't test it, but it's very likely that static linking doesn't work (well).
If someone has managed to build Lua statically on Windows and it worked with C modules, please lmk. For now I'm assuming it would produce a broken build.
Upvotes: 0
Reputation: 119
You should run msvcbuild.bat with static command line parameter.
Upvotes: 7
Reputation: 11377
I didn't test this, but you most likely need to use the /MT flag on each piece of the compilation you do. In this case, both your main program, and 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). Methinks that is your problem. Change it to /MT and see.
Upvotes: 4