Write in front
This article is about the use of the Linux g++ C++ development of some of the individual immature thinking, here only to record, give yourself a wake up, if can help to similar to my current situation of classmates, is also excellent.
The project needs to start the C++ process development. But the foundation of the situation is not C++ good, it is so long without any practical practice, more pit dad is to be familiar with the operation, but the development of the custom is not here in the Linux environment directly write code, Assi bar, feel the whole people are not good.
OK, Spit Groove finished, continue to write code.
g++ Start and other considerations
Talk Linux about under the C++ development, will inevitably mention gcc , g++ compiler, and so on, and so on Vim Emacs God's general existence, the sense that the gods are using such a high-end handy tool for development, I am not, see after is also the heart of the admiration, not consciously want to learn from the great God. However, a few days of the configuration environment has been frustrating, the use of the back is unthinkable Vim .
On the above artifact, the online introduction of a lot of information, self-access can be.
and combined with my actual situation, as well as the subsequent to record the small problem of the breakthrough process, the feeling is to be down-to-earth, even if you want to use also have a Vim certain knowledge of the reserve and then convert it over. From the familiar knowledge extension, migration to the unknown knowledge, the resistance will be correspondingly much smaller. Of course, if there is a great God with, at any time can absorb the experience of the actual combat faction, that can ignore the later part of the nonsense.
Background introduction
I currently use more development tools are a variety of high integration of the IDE, the main language is Java , therefore, Eclipse IntelliJ IDEA more familiar with, VS but also simple use over a period of time. The Linux system is familiar, but the Linux development of the next C++ is not confident. Two "unfamiliar" attribute overlay: Unfamiliar development environment + unfamiliar language, the confidence is very test.
Personal thinking
But in fact, the problem is not without solution, the main reason for personal feeling guilty is Linux G++ not familiar with the various commands under compilation (-C,-O,-G), and no expert guidance, so dazed and flawless. But refer to the official documents and other information, can be solved. Although it hurts to look at official documents.
About Tools
For the time being, the alternative tools are Linux below, g++ Eclipse IDE for C/C++ Developers recently not considered, Vim and Windows below Visual Studio , and can also include a variety of lightweight editors, such as sublime text 3 , and VS Code so on. Exclude short-term I can not master Vim and compiler g++ , the remaining main divided into IDE and editor, about how to choose, personally think the article [1] said very reasonable:
I think we should use the right tools to do something worthwhile and maximize efficiency, so I'll use Eclipse to write a Java project, write a Shell with Vim, write Javascript/html/python with Sublime Text, use Visual Stu Dio writing C #.
应当使用正确的工具去做有价值的事情,并把效率最大化, then the choice is self-evident. Linuxunder the use sublime text 3 of some C++ small Demo, found that the effect is not ideal for personal programming literacy requirements are high, of course, it is estimated that with code hint plug-ins will be much better, but why?
Considering, sublime text 3 not suitable for long-term development C++ , occasionally open individual files to adjust some simple errors, or quite suitable, of course, the replacement Ubuntu of the default document reader is also excellent. Therefore, the final selection is: command-line invocation g++ , Linux below, Eclipse IDE for C/C++ Developers and Windows below Visual Studio three.
In the end, it really worked out a way that wasn't "perfect", but the process was more interesting.
Specific operation
As suggested by the predecessors, you can move the Windows VS code down after writing the code below and Linux then compile and run.
Code is generic, there is no platform problem, so choose VS to write code, with its code hints, code formatting and other functions, the use of a lot more handy. As for choosing Eclipse or directly g++ or writing makefile files, look at the individual choice.
Problem description
In general, the biggest problem is the g++ unfamiliar command. It can only be learning new knowledge, or leveraging the mature IDE.
About parameters, article [2] very detailed, compared to man g++ see the information, exactly the same. can refer to the study.
If the IDE is simple, rough, write code, and then manipulate the tool, do not need to know makefile file writing and g++ command.
Explore –> Solutions
Eclipsewhen you look at Console the hints in compiling your code, you'll find that g++ commands appear, presumably Eclipse generated by yourself, and that Linux running these commands in the command window is correct. Bingo, follow the Eclipse prompts to go, the g++ operation command is enough.
The continuation of the observation will find that the Eclipse project was created with its own makefile file, just the compilation of the statement is here. Bingo, the problem once again get part of the solution, the heart feel more practical.
Here will find, in fact, Eclipse play is the actual combat experienced master role, rookie I observe the action of master, and then learn to improve themselves.
"Enough"
g++Command
Organize the g++ commands that appear as follows:
Compiled into. o File:
g++-O2-g-Wall-fmessage-length=0 -c-o Main.o Main.cpp
Generated. Out file:
g++-oMainMain.o
According to the compilation rules, only the changed source code will be recompiled; o file affects the subsequent. Out file, which is a dependency, continue compiling.
If the Eclipse commands above are not observed clearly, you can re-build them in the menu Project.
In fact Eclipse , it is also based on the operation of makefile, so makefile writing is the real key. About makefile, the article [3] introduced in very detailed, time-sufficient words are highly recommended reading study.
Summary and extension
A "no-presentable" approach to learning, but is a get new skills. And the way you learn is interesting, mark.
Reference articles
- [1] http://lucida.me/blog/sublime-text-complete-guide/
- [2] http://linux.die.net/man/1/g++
- [3] Http://www.chinaunix.net/old_jh/23/408225.html
g++ start