Building / Launching Lua from Visual Studio

I am a complete noob when it comes to linking and building with Visual Studio. I would like to integrate Lua into a C ++ console application.

Can someone give a step-by-step guide on how to do this, from getting Lua dependencies on lua.org, to actually launching "Hello World from Lua" in VS and all the steps between them.

Finding something like this on the Internet was very difficult, since most of them require prior knowledge of building Lua, etc.

Thanks:)

+4
source share
2 answers

Start with Lua for Windows . This will provide you with stand-alone batteries, including installing Lua. Lua for Windows is not an official distribution, but it is well respected by the Lua user community. You can use its lua.exe to gain experience with the language in the Windows environment, as well as use its rich collection of tested extension modules.

If you add your include and lib folders to your VS project configuration, you can compile and link to Lua in no time.

One possible complication is that the LfW distribution is built against the VC8 C runtime library. If this becomes a problem, you can either compile Lua yourself as part of your solution, or get the well-known good DLL that matches your specific version of Visual Studio from Lua Binaries .

Remember that if you use one of the distributed DLLs, it will be compiled as C, not C ++. This means that you must wrap any links to files with Lua support in extern "C" {...} or you will have problems with the linking.

It really helps to have some experience with configuring and building a VS project. In particular, the experience of mixing C and C ++ in a VS project is very useful.

+3
source

I heartily recommend following the advice already given about learning C and C ++ and mixing them together. If you have this under your belt, you can check LuaBind or LuaPlus to connect C ++ and Lua. You can do this manually (and you probably need to understand what is happening under the hood first), but it is more efficient and cleaner, by code, to use one of these linking libraries. For debugging purposes, Decoda is a good choice; it can connect to processes running in VS that contain the Lua code you want to check.

+1
source

All Articles