Outputting colored strings in Linux's Terminal

Jul 16, 2014 at 12:06pm
I am currently programming on Linux Mint using Eclipse, and since I hate the Eclipse console (because of its white background) I like to run my code using terminal. Now I know that if I were programming on windows that the line for outputting colored strings is:

1
2
system("Color 1A");
std::cout << "Hello World" << std::endl;



But this obviously does not work on Linux's terminal but only on Windows CMD, so is there a different command to output colored strings on Linux terminal or is feature only applicable to Windows?
Jul 16, 2014 at 12:12pm
Take a look at ncurses (google it).
Jul 16, 2014 at 12:22pm
Hey Chervil!

My eclipse isn't accepting the <curses.h> or <ncurses.h> library, I know you can download those manually but I'll leave that as a last resort since I would like to use this code on multiple computers without having to download the same library on each computer.

Are there any other libraries that would allow me to do this?
Jul 16, 2014 at 12:24pm
You can try looking into term.h for terminfo (included on most POSIX systems).
Jul 16, 2014 at 12:27pm
Hey NoXzema,

Eclipse did not have this library either but I do see it on the list of aptitude packages, is this something I need to download from there? And if so, exactly which package is the one I'm looking for?
Jul 16, 2014 at 3:24pm
Eclipse isn't going to have these libraries. That is up to you as the programmer to get these libraries. That's not the job of the IDE, and I'm not sure where you would have gotten that idea.

omurad wrote:
I would like to use this code on multiple computers without having to download the same library on each computer

You either bundle the library with your program, or you set a requirement for that library on your program. Generally, though, you want to just say the library is a dependency. Package managers handle this for users, so all they have to do is apt-get install your-program and the package manager will automatically download any dependencies they need.
Jul 16, 2014 at 3:48pm
Thanks you for the clear up ResidentBiscuit!
Topic archived. No new replies allowed.