IDE -> Command Line

Hi everyone! I was wondering if anyone knows a simple linux command line c++ comiler. Something like NANO but for c++... Thanks!
*NOTE* Nano supports c++ highlight but doesnt have a comiler...
Nano is a text editor. A text editor is not a compiler. Some text editors support tool integration, and I expect that's what you want.
Why is Tmux / GNU Screen / a second login / job-control not good enough?

I can recommend stuff to you but the recommendation will be better if you tell me what exactly you want from your editor. For example, does "have a compiler" mean you just want to call the shell from your editor? Or do you want (e.g., on-the-fly syntax checking?)
If you want console editor with C++ syntax highlighting, then most use vim or emacs. They are a bit different - I found vim easier to learn, but emacs is more powerful if you use plugins and learn Lisp. Using both requires some reading of tutorials at first. As for IDEs, i think only emacs can be used as fully-functional console IDE. Most people in console-mode use text editor to edit code, and run compiler using command line and make files. For source code navigation you can add ctags/cscope to both vim or emacs.
Most other IDEs for Linux are graphical, but even with GUI I rarely see anyone using IDE built-in functions to compile project, as make files are more powerful and universally available.
Last edited on
The "compile command" in Emacs invokes
make -k

by default. In other words, you need the Makefile. The compiler output goes to separate Emacs buffer and error messages act as hyperlinks to relevant point in the source code.


There are other tools, such as 'GNU Build System' and 'cmake' that help to generate and maintain a Makefile.


Most Linux distro's have some sort of "package management". Utilities that simplify installation/update/removal of "software packages", e.g. a compiler suite. Simple text editor packages do not include any compiler. Those packages at most require a compiler package. If your distro does not have a C++ compiler installed by default, then study its package management tool. GCC should be ubiquitously available.
you don't need a makefile for simple code though.
just run g++ filename for simple stuff. If you get to the point that you need a makefile to handle a ton of files etc, you can go there as needed.

Linux has been held back by lack of a solid IDE for decades. I don't even know what is current; last thing I tried was eclipse which ate my project 3 or 4 times so I went back to develop in visual studio and migrate to unix after it was working. That sort of works, if you use portable libraries like qt for your guis or opengl for graphics etc. You can even throw Cygwin on the machine and compile with g++ and develop in visual.

Well this is starting to get off topic now, but I wanted to reply to the following.

jonin wrote:
Linux has been held back by lack of a solid IDE for decades.


Just wondering what you mean by that exactly? What IDE's have you tried? And what specific features are you looking for?

Have you tried KDevelop? It's a mature application which can have other technologies like sfml, opengl, Qt and others integrated into it. It is also capable dealing with over 60 different languages / scripts - provided one has the appropriate compiler / interpreter installed.

jonin wrote:
I don't even know what is current; last thing I tried was eclipse which ate my project 3 or 4 times so I went back to develop in visual studio and migrate to unix after it was working.


What do you mean by "ate my project" ? Presumably you weren't using version control? A lot of IDE's have GUI support for git. It seems "a long way around the mulberry bush" to develop in VS then migrate to a version of Unix/Linux.

For Qt, I just use QtCreator IDE - it works fine.

jonin wrote:
just run g++ filename for simple stuff.


One should always compile with at least:

g++ - std=c++17 -Wall -Wextra -pedantic-errors *.cpp -o Exefilename

I am sure you know this already, but I mention it because we shouldn't be promoting appallingly minimal procedure.

For the option involving the standard, substitute the latest one your compiler can handle, although it's easy to update, so IMO one should always have the latest.

With makefiles, my IDE's use a bash script which generates the makefile automatically - so I don't even worry about it.

As for learning while using a text editor instead of an IDE approach - it has it's pro's and cons. The advantage is that you will learn very well because you will have discovered the hard way (this is the con) what your mistakes were. I first learnt C language in 1988 by teaching myself from the K&R book, with no internet and no one to talk to, and no IDE. Sometimes it would be several days before I realised what dumb mistake I had made. These days IDE's have background compilation which will tell you about errors and warnings as you type.

An example of a disadvantage of using an IDE, is that one has to learn ones way around the IDE - where do I put in the compiler warning options? But if one is going to use vim or emacs, there is a substantial amount to learn there too.
You are correct. g++ filename is just for classroom level stuff, you do need some more parameters for anything substantial.

Its been a while but I can't recall any unix IDE that had a decent wysiwyg gui editor (qt is nice but its weird and looks nothing like the result), auto completion of class fields, profiling .. those were the big 3 that nothing seemed to have down at even close to vs levels. Eclipse was the best one I tried, and if it had not lost the project multiple times, I might have stuck with it. I vaguely remember kdevelop, but not what it was lacking.

ate my project: it corrupted its internal project files and I had to keep going back to the source code and re-creating it. Version control was only set up on the code proper as it was a pilot to see if we wanted to use it.



g++ filename is just for classroom level stuff, you do need some more parameters for anything substantial.


Can I disagree?

Warnings are one's best friend - who needs them more than a beginner? I use these additional ones, which are not enables by the above options:
http://www.cplusplus.com/forum/general/183731/#msg899203

Its been a while ....


Maybe a few years ? Because all the IDE's I have used do all these well: auto completion of class fields, profiling

it corrupted its internal project files


I have never had a problem with that.

Version control was only set up on the code proper as it was a pilot to see if we wanted to use it.


Yep, do the whole thing: all the directories :+)
If you have some experience with bash scripts, even just the minimal of knowing variables and command execution, then look into makefiles.

It lets you basically create a local script file where you make variables with the program to run (like g++ or clang++), variables with the commands that the program should be run with, and then variables with the actual files you want to include. Finally it is all run with the simple command
$make

You also then get the option of 'targets', but that's for different compile options that you also set up.

https://docs.cs.byu.edu/wiki/Makefiles


As far as my text editor, I use vim with an auto-complete plugin: http://vi.stackexchange.com/questions/82/how-to-get-intelligent-c-auto-completion
Last edited on
Topic archived. No new replies allowed.