Jump to content

C and C++ without an IDE on Ubuntu 14.04


sKunKbad

Recommended Posts

I've been playing around with C and C++ on my Ubuntu machine. I tried it once on Windows and I didn't have a good experience because I didn't like using the Visual Studio. I like to write code, so really prefer a text editor over an IDE.

 

This weekend I found that it is super easy to write and run C and C++ programs on Ubuntu. GCC was already installed, and after installing G++ I could compile C++ programs easily. I just used my text editor, which is all I really want to use.

 

The only thing I was struggling with, and it could be the reason why I may need an IDE, is debugging. The error messages that GCC and G++ are giving are not very awesome, and sometimes I would compile the program without error, just to find that it gives a "segmentation fault" or other errors that offer no information.

 

So am I forced to learn and use an IDE, or are there debugging tools I should use instead? If you don't use an IDE, what do you use, and how do you debug?

Link to comment
Share on other sites

You aren't forced to use an IDE. If you compile your program appropriately you can use gdb as your debugger and step through the entire execution. (There are undoubtedly GUI frontends to it too.) An IDE does basically that but makes the experience much easier - not to mention the other features they can provide that mere text editors cannot.

The kind of help you're hinting at though, especially regarding segfaults, is harder to come by. Most of the time you'll only get warnings, if anything, from your compiler; you're expected to know what they mean so the work is to find and fix the problem. GDB can give you more information if you know how to ask it.

 

Sorry you don't like VS. I love it. If there was a (free, stable, up-to-date) plugin for PHP then I would switch from NetBeans without a second thought.

Link to comment
Share on other sites

GDB is the main command line debugger. Some IDE's simply interface with this rather than having their own debugging routines. You can google for a tutorial to cover the basics of GDB and get started with setting break points and stepping through the code. IDE's make the debugging process much simpler and more user friendly but are certainly not required.

 

Another tool you'll likely want to look into which can help with memory problems such as corrupted data and segmentation faults is Valgrind. It will report back any attempts you make to access (read or write) memory locations that you should not be.

Link to comment
Share on other sites

Thanks for your responses. I'm going to check out GDB.

 

Maybe I'm wrong about IDEs, but I'm just getting into this. Nearly 100% of my experience with coding is PHP, JavaScript, and web oriented technologies. It's kind of exciting to do something really different.

Link to comment
Share on other sites

There's nothing wrong with spending some time with just a text editor and a console and learning gcc/g++, make files, gdb, etc. You can learn quite a bit about the inner workings of the software development process and what happens when you hit the 'Build' button in the IDE.

 

The IDE's generally provide a lot of nice features to help speed up development and reduce the amount of stuff you need to remember or lookup. For instance in most IDE's setting a break point on a particular line in an IDE is usually a simple matter of clicking in the margin to toggle the breakpoint. With GDB on the command line you'd have to type a command such as br thefile.c:1234 meaning you need to know the name of the file and the exact line number. Not complicated information to find, but also something you shouldn't need to do. There's numerous other things an IDE will help with which while possible w/ gdb or other manual tools are simply more cumbersome.

Link to comment
Share on other sites

  • 3 months later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.