Sign in to follow this  

Flexible C++ linux IDE (a specific problem)

This topic is 4840 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is there a flexible C++ linux IDE? I've just encountered a problem with Anjuta that doesn't allow me to store files in my own directory structure. Apparantly Anjuta *requires* my files to be in a SRC directory located in the directory of the project file. Frankly, this requirement is rediculous: I have my files structured according to a specific hierarchy and IDE specific project files are located in one of the folders. It's logical to keep platform independent files *above* that folder but it seems like I can't do that with Anjuta. Does KDevelop allow for flexible directory structures? If not, can someone recommend another IDE? I will install KDevelop tomorrow but I'd like to keep my options open. Also, I am considering using XEmacs for my development needs but being a complete emacs n00b I have a few questions about its C++ development mode. Does it actually maintain makefiles or do I have to do it manually? If someone can give me some overall direction, that'd be great.

Share this post


Link to post
Share on other sites
anjuta has been a real bitch for me lately, and I've just kinda moved into managing makefiles myself and using gedit.

that's probably not what you were hoping to hear.

Share this post


Link to post
Share on other sites
Not really [smile] I want to spend my time developing the software, not managing things that can be completely automated by the tools without any real loss of freedom. I'm wondering if emacs can manage makefiles or I have to do it manually...

Share this post


Link to post
Share on other sites
well, from the pratical side of things...

how often are you adding files to your projects?!

I mean, in the beginning sure, but after that initial phase, generally its jus about coding stuff in the current files.

Share this post


Link to post
Share on other sites
You don't need to add files or fix dependencies or anything.

The trick is to use the "wildcard" rules of GNU make, and to use the "-MMD" option of gcc to emit a ".d" file together with the .o files. Then use -include in the Makefile to include the .d files; if they're not yet generated, then that won't be an error, but that also means that the .o files are not generated, so the target will be re-built no matter what.

Here's a sample make file I use (sources go in src/, build stuff that can be cleaned goes into bld/). Any .cpp file in src/ is automatically built as part of the executable "myprog". If you change a header used by any of the cpp files, the right files will get magically re-built!

[source language=make]

OFILES:=$(patsubst src/%.cpp,bld/%.o,$(wildcard src/*.cpp))
LIBS:=-lstdc++

bld/myprog: $(OFILES)
$(CC) -o $@ $^ $(LIBS)

bld/%.o: src/%.cpp
$(CC) -c $(CFLAGS) -MMD -o $@ $<

-include $(patsubst %.o,%.d,$(OFILES))

clean:
rm -f bld/*



Share this post


Link to post
Share on other sites
I'm amazed. I will try your makefile the next chance i have. What's the deal with automake / autoconf if it so easy just with gcc?

Share this post


Link to post
Share on other sites
Quote:
Original post by hplus0603
You don't need to add files or fix dependencies or anything.

Thanks for the great example! I'll try to use it when I get home. If you modify cpp files, this rebuilds the affected modules? Also, out of curiosity, what editor do you use for development?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by hplus0603
You don't need to add files or fix dependencies or anything.

The trick is to use the "wildcard" rules of GNU make, and to use the "-MMD" option of gcc to emit a ".d" file together with the .o files. Then use -include in the Makefile to include the .d files; if they're not yet generated, then that won't be an error, but that also means that the .o files are not generated, so the target will be re-built no matter what.

Here's a sample make file I use (sources go in src/, build stuff that can be cleaned goes into bld/). Any .cpp file in src/ is automatically built as part of the executable "myprog". If you change a header used by any of the cpp files, the right files will get magically re-built!

*** Source Snippet Removed ***


Does this also take into account included headers, e.g. :

main.cpp includes foobar.h which includes bar.h
now if I change something in bar.h, does it rebuild main.o ?

Share this post


Link to post
Share on other sites
I've used a good few text editors and IDE's and by far my favorite is JEdit (www.jedit.org), it,s much more user friendly than emacs or vi and has a load of really handy plugins such as FTP file access and Gesture recognition (e.g right click and move mouse up to create a new file etc.)

developing in c++ this year for a year long proj. i'm using
->Jedit
->g++
->makefiles
->ddd (debugger)

and a few other tools

just said i'd throw in my piece :)

Share this post


Link to post
Share on other sites
Thanks for the tips. There are a lot of great text editors (especially ones targetted at programmers) but I'm particularily worried about managing makefiles. I guess one of the reasons is that I'm new to unix development and know little about them so they scare me [smile] In particular, I'm quite ignorant about the purpose of automake and its proper usage (and whether I need it at all). Whenever I get the chance (tonight or tomorrow) I'll try KDE as well as hp's makefile and see where that gets me. If managing makefiles really doesn't require that much work, I may actually go with a good text editor instead of a fully featured IDE.

Share this post


Link to post
Share on other sites
Quote:
Original post by hplus0603
You don't need to add files or fix dependencies or anything.

The trick is to use the "wildcard" rules of GNU make, and to use the "-MMD" option of gcc to emit a ".d" file together with the .o files. Then use -include in the Makefile to include the .d files; if they're not yet generated, then that won't be an error, but that also means that the .o files are not generated, so the target will be re-built no matter what.

*** Source Snippet Removed ***


Wow, hplus0603, this trick is awesome. i knew the -M option of gcc; i had a make target which i had to call manually, something like:

gcc -M *.cpp *.c > Makefile.in

and then

~include Makefile.in

in my Makefile. this sucked, and it didn't work when i changed include files in other directories... Thanks, you get the best rating i can offer :)

chris

Share this post


Link to post
Share on other sites
Quote:
Original post by CoffeeMug
Thanks for the tips. There are a lot of great text editors (especially ones targetted at programmers) but I'm particularily worried about managing makefiles. I guess one of the reasons is that I'm new to unix development and know little about them so they scare me [smile] In particular, I'm quite ignorant about the purpose of automake and its proper usage (and whether I need it at all). Whenever I get the chance (tonight or tomorrow) I'll try KDE as well as hp's makefile and see where that gets me. If managing makefiles really doesn't require that much work, I may actually go with a good text editor instead of a fully featured IDE.


By the way, please don't think that all the Linux programmers use applications like Emacs. :) I find it ones of the most unintuitive programs I've ever used in my life. Applications like Anjuta, JEdit, Kate, Eclipse, KDevelop etc. are far easiest to use and just as good.



Makefiles are a little scary at first, but they are very flexible and powerful. For example, you can add targets for running unit tests, deploying your server over the network etc. Once you've found a script for compiling and linking your project, you never have to think about it again so don't worry about the odd syntax.

Combine all this with version control systems like CVS and you have a very powerful development environment. You might miss the all in one IDEs like MSVC, but I find this approach of using many small but specialised tools together much more flexible.

Share this post


Link to post
Share on other sites
Quote:
Original post by CoffeeMug
Sean, then what is the purpose of automake? Should I bother with it or just bite the bullet, learn the GNU makefile syntax, build it once and forget about it?


I'm not sure to be honest. :)



I grabbed black magic code like hplus0603 uses, put it in a makefile and never thought about it again. I work with many different languages so I've never spent the time to understand how code like that works.



Just go through some makefile tutorials to get to grips with it. The only things you really need to know are targets (what task depends on what other task, how it is achevied and what files they produce), macros (like C macros) and apart from that it's just a straight forward script file. They can look very cryptic though, so don't be put off. Unless you're doing something special, you should just be able to take someone elses generic makefile and change some path names to get it working.

Share this post


Link to post
Share on other sites
You may want to check out Jam as well. It makes maintaining project files a lot easier then dealing with Makefiles. We use it on our projects with no problems. You can even define your own rules for building different targets.

I've heard that you can setup Anjuta to use jam but I've never tried it. I use vim/kate most of the time.

-----------
Andrew

Share this post


Link to post
Share on other sites
Hey, I just thought I'd throw my $0.02 worth in as well. I have tried several IDE's in Linux and I must say that the best thing I have found is Source Navigator by RedHat. You can find it at:

http://sourcenav.sourceforge.net/

It hasn't been updated in over a year, but it is stable and works well. About the only thing it doesn't provide is code-completion and *intellisense* stuff. Then again, is there anything on linux that actually provides this stuff that is on par with Visual Studio? Haven't found it yet...

The only downside to the program is that you are working on a very large project, it sometimes takes a little while to load a symbol's cross-reference (where the symbol is defined, etc).. Then again, I was using SNavigator with Torque, and that's huge...

Anyways, maybe it's for you, maybe not... just thought I throw that out there.. I've tried Anjuta, KDevelop, etc, and I always find something wrong...

-Greg

Share this post


Link to post
Share on other sites
Quote:
Original post by CoffeeMug
Sean, then what is the purpose of automake?

In short, it takes the verbosity out of writing good, flexible makefiles. Automake ends up outputting a "GNU style" makefile that checks dependencies and does everything the correct way for the list of files you tell it to handle. So, you do end up telling it which files to handle (without outside tools; but it's really easy once you have it down), but automake does the rest of the work turning it into a huge makefile.

Like others have said, there are alternatives to makefiles (e.g., jam) that do make things more simple (and, arguably, more easy). I stick with makefiles because they do what I need simply and they fit together perfectly with the rest of a GNU build environment (as one would hope).

Share this post


Link to post
Share on other sites
automake also does the most important thing of all:

simplify installation.

automake does it all for you. and defines some macros that say where stuff was installed.

That's REALLY what automake does. the rest could easily be done with autoconf and a simple makefile.

Share this post


Link to post
Share on other sites
Well, I tried out a lot of different things today and I think I found a winner. I'm pretty excited about this little piece of software and I strongly encourage everyone to try it.

Parinya.

I won't talk much about the features, you can read about them on the site. I'll mention my opinion of what I've seen so far. Very lightweight (starts up in less then a second on my Athlon 750, Anjuta takes about 5-10 seconds). The GUI isn't very pretty (but in my experience linux IDEs generally aren't). Creates project templates very quickly (as opposed to 30 seconds in Anjuta) and compiles immediately (no make, config, etc.) Allows exporting makefiles whenever necessary. Has limited autocompletion. The GUI feels like MSVC (the menu structure is similar, even some icons and shortcuts are similar). Allows me to put my files wherever I like (unlike Anjuta). Integrated debugger seems pretty good (from what I've tried so far). Code editor is nice (keyword highlighting, block collapsing, tabs).

Please, if you develop for linux, download it and take a look. This is exactly what I've been looking for and I'd feel bad if people didn't discover it. This may be exactly what you need.

Thanks everyone for your responses. After I get further into my project I'll post my experiences about setting up everything necessary for cross platform development. May be an article or something. Let me know if you think that would be useful.

Share this post


Link to post
Share on other sites
Well, it has limited intellisense. In some cases it shows tooltips with the names and types of parameters whenever you write code to call a function. It doesn't exactly parse every part of C++ grammer and show you hints as you type but limited support is better than no support.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by Tha_HoodRat
TRy CbuilderX from borland.Ihave tried anjuta, Kdevelop, MingWstudio and CbuilderX is the best so far. I am however migrating to using makefiles the IDE thing is not working well for me.

How is not working? I use Borland BuilderX and it works perfectly.

Share this post


Link to post
Share on other sites
Sign in to follow this