C ++ and Lua with USB

So, about 2 weeks ago, I started learning C ++ and Lua, and I would like to be able to:

  • compile the code in C ++ (it would be nice if I had a C compiler, like the next one on my list of languages ​​to learn).
  • interpret (is that the right terminology?) Lua and
  • do it all from my USB drive WITHOUT downloading anything from the Internet or changing the path variable. (I will mainly work on school computers.)

As a note, I fell in love with Sublime Text 2 (the portable version of which is already on my USB drive). If it is absolutely necessary, I can do without it, but I would prefer to use it wherever I am.

Please be patient with me, as I mentioned earlier, I just started to learn how to program, and I have little knowledge about how everything works. I saw similar questions, but they never seem to help me much because of my limited knowledge , so PLEASE do not mercilessly close my question like the others I saw on this site.

Thank you in advance!

+1
source share
4 answers

I recently added a page on Lua WIKI (an excellent source of information) that can help you. This is a tutorial for complete beginners on how to create Lua from sources using only free and “portable” ones (in the sense of “you can put on USB sticks” tools). It is intended for Windows users. Do not forget to check the official page and the main site of Lua !

The fact that you cannot download anything is pretty restrictive (how could you get a free compiler?). In any case, as the great wolf said, TDM-GCC is a great C / C ++ compiler for 32-bit x86-PCs. It is also fixed to be completely “portable”: I usually use it with a portable USB HD. The tutorial that I mentioned shows how to download and install it.

Note that although your system administrator at school may have blocked your ability to change the path variable globally, you can set it for individual processes (“running programs”) using simple batch files (also called Windows shell scripts).

Create a file called "myshell.cmd" with this content:

@set path=%path%;c:\the\path\to\my\app&cmd /K 

part of c:\the\path\to\my\app should be the actual path to the directory (folder) where the application executable is located. When you double-click on myshell.cmd , a black box will open (provided that your sysadmin has not blocked this function), where you can call the executable files of the application.

For example, if you "installed" the TDM_GCC compiler in c:\myprogs\GCC inside this directory, you will find a subdirectory named bin . This subdir should be put in the path, so your myshell.cmd file will look like this:

 @set path=%path%;c:\myprogs\GCC\bin&cmd /K 

Then in the black box that I mentioned, you can call the compiler command:

 gcc --help 

As for your learning path, if you intend to learn Lua and C or C ++, I suggest you try C instead of C ++. C ++ has more “higher-level” functions, but it is huge, and although Lua can use the built-in C ++ code (of course, this is an advanced topic), it is intended for direct implementation in a C application (it has an API that complies with C conventions ), so for a beginner, probably the path Lua → C → C + Lua will be a little easier. C in itself, although difficult to learn, is a fairly minimalistic language, so the information for digesting about it is not so great.

Do not discourage you, but IMO, both C and C ++ are not the most suitable languages ​​for absolute beginners (they have many pitfalls and almost no "security systems" for beginners). But it depends on your skills, dedication and motivation ,-)

Hope all this helps.

+4
source

For windows,

Take a look at

http://nuwen.net/mingw.html

You should be able to extract the download to the usb directory. Then you can click on the .bat file to open a command prompt with the correct path settings.

As a bonus, it already includes a pre-installed boost that will simplify the use of C ++.

+2
source

Lua is trivial. Download the binaries, put them on your disk and configure Sublime Text to call them in Lua files.

C / C ++ is more complicated just because the range of options is so vast. I am using the 2003 version of Microsoft Visual C ++ that covers my needs. I found a copy here .

Keep in mind that C ++ is a much more sophisticated (non-strict) C superset, so you will learn most of C as you learn C ++. IMO, learning C is better at first for a number of reasons. You will hear some people claim the opposite, but in this case there is clincher: Lua is written in C and its API is developed for C. By exposing idiomatic C ++ (i.e. objects), Lua is a big ball of complexity, which you just don’t need it right now, learning two languages.

0
source

For the C / C ++ part, it is also recommended to start with C. Not for ideological reasons, it's just a lot easier if you are trying to develop compilation / linking basics, etc.

As the first C compiler, I would recommend the tiny C compiler

Tiny c compiler

This is one of the easiest that you can see around, which I saw, and you can still create lua libraries, etc.

Once you feel comfortable, then switching to one of the more powerful environments, such as gcc under MingW or Visual C ++, should be a little less complicated.

0
source

Source: https://habr.com/ru/post/952133/


All Articles