来自 USB 的 C++ 和 Lua
所以大约 2 周前,我开始学习 C++ 和 Lua,我希望能够:
So about 2 weeks ago, I started learning C++ and Lua, and I would like to be able to:
- 编译 C++ 代码(如果我也有一个 C 编译器,那将是一个不错的奖励,因为这是我要学习的语言列表中的下一个)
- 解释(这是正确的术语吗?)Lua,和
- 从我的 USB 驱动器完成所有这些操作,无需从 Internet 下载任何内容或更改路径变量.(我将主要在学校的计算机上工作.)
顺便说一句,我已经爱上了 Sublime Text 2(它的便携式版本已经在我的 USB 驱动器上).如果绝对有必要,我会不使用它,但我更希望无论走到哪里都能使用它.
As a side note, I have fallen in love with Sublime Text 2 (the portable version of which is already on my usb drive). If it's ABSOLUTELY necessary, I'll make do without it, but I would prefer being able to use it wherever I go.
请耐心等待,正如我之前提到的,我刚刚开始学习如何编程,我对事情的工作原理知之甚少.我见过类似的问题,但由于我的知识有限,它们似乎从来没有帮助过我,所以请不要像我在本网站上看到的其他人一样无情地结束我的问题.
Please be patient with me, as i have mentioned before, I just started learning how to program, and I have little to no knowledge on how things work. I have seen similar questions, but they never seem to help me much due to my limited knowledge, so PLEASE don't mercilessly close my question like others I have seen on this site.
先谢谢你!
推荐答案
我最近添加了一个页面 在 Lua WIKI(信息的重要来源)上可能会对您有所帮助.这是一个完整的新手教程,介绍如何仅使用免费和便携式"(在可以放在 USB 驱动器上"的意义上)工具从源代码构建 Lua.它适用于 Windows 操作系统用户.不要忘记查看官方入门页面和Lua 主站点 以及!
I recently added a page on Lua WIKI (great source of info) that may help you. It is a tutorial for complete newbies on how to build Lua from the sources using only free and "portable" (in the sense of "can be put on usb drives") tools. It is meant for Windows OS users. Do not forget to check the official getting started page and the main Lua site as well!
你不能下载任何东西的事实是非常严格的(你怎么能得到一个免费的编译器呢?).无论如何,正如greatwolf 提到的那样,TDM-GCC 是适用于 32 位 x86 PC 的出色 C/C++ 编译器.它也被修补为完美的便携":我通常从便携式 USB HD 中使用它.我提到的教程向您展示了如何下载和安装".
The fact that you cannot download anything is quite restrictive (how could you get a free compiler then?). Anyway as greatwolf mentioned TDM-GCC is a great C/C++ compiler for 32 bit x86 PCs. It is also patched to be perfectly "portable": I usually use it from a portable USB HD. The tutorial I mentioned shows you how to download it and "install it".
请注意,尽管您在学校的系统管理员可能阻止了您全局更改路径变量的能力,但您可以使用简单的批处理文件(也称为 Windows 命令外壳脚本)为单个进程(启动的程序")设置它.
Note that although your sysadmin at school may have blocked your ability to change the path variable globally, you can set it for individual processes ("launched programs") using simple batch files (aka Windows command shell scripts).
使用以下内容创建一个名为myshell.cmd"的文件:
Create a file named "myshell.cmd" with this content:
@set path=%path%;c: hepath omyapp&cmd /K
c: hepath omyapp
部分必须是应用程序可执行文件所在目录(文件夹)的实际路径.当您双击 myshell.cmd
时,将打开一个黑框(假设您的系统管理员没有阻止此功能),您可以在其中调用应用程序可执行文件.
the part c: hepath omyapp
must be the actual path of the directory (folder) where the application executable is placed. When you double-click on myshell.cmd
a black box will open (assuming your sysadmin hasn't blocked this feature) where you can invoke the app executables.
例如,如果您在该目录内的 c:myprogsGCC
中安装"了 TDM_GCC 编译器,您将找到一个名为 bin
的子目录.该子目录必须放在路径中,因此您的 myshell.cmd
文件将如下所示:
For example, if you "installed" the TDM_GCC compiler in c:myprogsGCC
inside that dir you will find a subdir named bin
. That subdir must be put in the path, so your myshell.cmd
file will be like this:
@set path=%path%;c:myprogsGCCin&cmd /K
然后在我提到的黑匣子"中,您可以调用编译器输入:
Then in the "black box" I mentioned you can invoke the compiler typing:
gcc --help
至于你的学习路径,如果你打算同时学习 Lua 和 C 或 C++,我会建议你尝试 C 而不是 C++.C++ 有更多的高级"特性,但它是巨大的,虽然 Lua 可以嵌入 C++ 代码中使用(当然这无论如何这是一个高级主题),但它被设计为直接嵌入到 C 应用程序中(它有一个API 符合 C 约定),因此对于初学者来说,路径 Lua --> C --> C+Lua 可能会更容易一些.C 本身虽然很难掌握,但它是一种相当简约的语言,因此需要消化的信息并不多.
As for your learning path, if you intend to learn both Lua and C or C++, I will advice you to try C instead of C++. C++ has more "high-level" features, but it is huge and although Lua can be used embedded in C++ code (of course this is an advanced topic anyway), it is designed to be directly embedded in a C application (it has an API which conforms to C conventions), so for a beginner probably the path Lua --> C --> C+Lua would be a bit easier. C in itself, although difficult to master, is a rather minimalistic language, so the information to digest about it is not that big.
不要让您气馁,但 IMO C 和 C++ 都不是绝对初学者最合适的语言(它们有很多陷阱,几乎没有初学者的安全网").但这取决于您,这在很大程度上取决于您的技能、奉献精神和动力;-)
Not to discourage you, but IMO both C and C++ are not the most suitable languages for absolute beginners (they are plenty of pitfalls and have almost no "safety nets" for beginners). But that's up to you, it heavily depends on your skills, dedication and motivation ;-)
希望所有这些都会有所帮助.
Hope all this helps.
相关文章