Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lua in visual studio 2012? [closed]

I'm looking at beginning to learn Lua and was wondering if it is possible to edit, run and debug Lua code in Visual Studio 2012 in a C++ environment. I have looked about and found that there are plug-ins for visual studio 2008 and 2010, but currently cannot seem to find any information on what I am looking for.

A good starting point would provide syntax highlighting for Lua code. Integration with the debugger would be nice. The ability to debug seamlessly between Lua code and C or C++ library code would be an ideal.

If not VS2012, then what IDE should be considered?

like image 202
Elliott Avatar asked Apr 30 '13 14:04

Elliott


1 Answers

have found this one: http://techneilogy.blogspot.de/2012/02/compiling-lua-with-visual-studio-2010.html

Compiling Lua with Visual Studio 2010

Download Lua

  1. Download the desired Lua sources from http://www.lua.org/ At the time of this post, a link to the latest sources can be found at the top of the page: http://www.lua.org/download.html

  2. The latest release is compressed in gzip (.gz) format; if you don’t already have something that can decompress this, there are a number of utilities available for free or little charge (personally, I prefer 7-Zip). You can decompress it somewhere as a backup, or else you can decompress it directly after creating a Visual Studio project.

Create a VS2010 C++ Project

1) Open Visual Studio and create a new Visual C++ project. The type of project you want to create is the one listed in Visual Studio 2010 as File => New => Project… => Visual C++ => General => Empty Project. Call it whatever you like, e.g. just “Lua” if it won’t conflict with any other version of Lua you’re using, or perhaps “Lua52” if you want to keep track of the version.

2) Copy or decompress the Lua source files into the default place where Visual Studio puts C++ files. In VC++ for VS2010 this is in the project folder under the solution folder. (If you’re unsure, create a temporary .h file and look at where VS has put it.)

3) Now go back into Visual Studio and add the files into the solution from the Solution Explorer window using the Add => Existing Item… option. Add all files with a .h or .hpp extension under “Header Files” and all the files with a .c extension under “Source Files.”

Compile Lua

1) If you try to compile the project at this point, you’ll get an error message similar to:

luac.obj : error LNK2005: _main already defined in lua.obj

This is because the Lua distribution includes main files for both the Lua REPL / file interpreter (lua.c) and the byte code compiler (luac.c).

2) For present purposes, you want the interpreter “lua.c,” so remove the compiler “luac.c” from the project. Now do a rebuild all.

Run Lua

1) If the rebuild all succeeds, you should be able to run the Lua REPL either inside Visual Studio, from Explorer, or from a command prompt. The result should look something like this:

2) Try entering a few lines as a test:

3) You can also run Lua program files from the command line by following the name of the executable with the Lua program file name. That’s all there is to it. Now you can begin exploring Lua as a language and as an embeddable interpreter. No doubt you’ll write a “hello world,” a Fibonacci generator, etc. If you want to try adding commands to the language itself in C code, you can try creating a function with your name, etc. And check out the resources available from links on the Lua site, including the “batteries included” versions, and tips for compiling Lua under Windows using other configurations (including links to a few complete projects).

like image 164
Leo Chapiro Avatar answered Nov 11 '22 07:11

Leo Chapiro