In another thread (that has been closed), someone asked about using an IDE versus just invoking the compiler/linker via a command line. Since I just started Linux C programming a few weeks ago, I'd like to give my own observations/opinions to a fellow programming newbie. I realize that others may disagree with these observations/opinions, but that doesn't make my own invalid. In fact, since the OP has already expressed a frustration over some of the very same things I found frustrating, it's likely that my observations/opinions would be more applicable to him than the opinions of someone who would simply disagree without having any empathy/understanding for the OP's point of view.
I have to say that I love IDEs. A good IDE should have a logical, easily-navigated UI to create applications. The UI should allow the enduser to easily enter all of the data needed to compile/link the app, and the IDE _should_ do whatever needs to be done to successfully invoke the compiler/linker to create the app.
An example of a good IDE that does exactly that is Microsoft's Visual Studio. It uses fully complete wizards to guide the process, and its underlying tools are well integrated with the IDE. When you finish the wizard, Visual Studio directly creates the needed makefile. It's easy and painless to develop Win32 apps using MS tools.
An example of a bad IDE that doesn't do this very well is Anjuta. Anjuta's wizard takes you only half-way gathering all the info it needs, then it runs some not-so-well-integrated GNU tools which, too independently of Anjuta, try to analyze your system and come up with the remaining necessary info to create the makefile. It's painful and difficult to develop Linux apps with Anjuta.
Part of the problem is that Anjuta is buggy. It recently got a _long-overdue_ update, but I get the impression that too little development time is being devoted to a tool that needs much more attention than it gets. Sometimes Anjuta works and sometimes it doesn't. For example, once I got the scintella editor to work on editing source files, but usually that locked up Anjuta as soon as I selected it, and I had to use the GtkTextEditor (or whatever it was called) instead. Of course, I haven't used the latest Anjuta version because I couldn't get the thing to compile on my system, using the previous version of Anjuta, and the "Anjuta project file" with the newer sources. When an IDE can't even make a new version of itself, given its own project file, that's a really bad sign. The Ubuntu repository still doesn't have the newer Anjuta. And I needed the newer Anjuta because I used Glade2 to create my UI, and the older version of Anjuta didn't support it.
So right there, I'd advise you to swear off of Anjuta, because I don't believe the support is as good as it needs to be for hassle-free development.
Another part of the problem is that Anjuta uses a lot of the GNU tools (autoconf, automake, etc), which strive to create "universal" dev files that take into consideration every possible configuration quirk of the thousands of Linux distributions made by Tom, ****, Harry, and their dogs Spike, Fido, and Spot. But this is a nightmare for a newbie who wants to just compile, link, and run his C/C++ program on his single installation of Ubuntu. He doesn't need to take into consideration some quirk of "Martian Christian Linux", yet another pointlessly trivial variation of Linux which, for god knows what reason, is supposedly better for Martians who also happen to be christians. The GNU tools spout out dev files that are humanly unreadable and uneditable by all but the extraterrestrial beings who devised the incomprehensible, needlessly convoluted alien "language" that these tools use. This is bad news if you need to hand modify one of these files because Anjuta didn't quite get something right (and believe me, it's a good bet that Anjuta's "output window" will demonstrate blissful ignorance as it chuffs out autoconf error messages telling you to hand edit your configure file to add this or that). Anjuta isn't smart enough to parse the error output of the GNU tools and follow the instructions given to you, even though it's supposed to be the job of a good IDE to maintain and "edit" the underlying compiler/linker support files instead of telling you to do so. Otherwise, what's the point of an IDE?
For this reason, I opted to get rid of Anjuta. I simply installed gcc, and all the dev libraries I personally needed, such as libglade2, gtk2, etc. Then I wrote my code with gedit, created a simple makefile for my needs, and just ran the make utility for a terminal window. It worked for me much better for me than Anjuta did.
One of the real breakthroughs I made with regards to specifying libraries in a makefile is use of the utility pkg-config, with its --cflags and --libs options. These options will look up the Include path, and library path of a particular package. For example, open a terminal window and type:
pkg-config --list-all
This will list all of the packages installed on your system. Let's assume that you've installed gdk2 (Gnome) package, and so "gdk-2.0" appears in the list. Now type
pkg-config --cflags gdk-2.0
This will spit out a line such as:
-I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include ... etc.
It is essentially what you supply to gcc when you want to tell it all the paths to the include files for an app that uses gdk2.
Now type
pkg-config --libs gdk-2.0
This spits out a line that is what you supply to gcc when you want to tell it all the libs to link to for an app that uses gdk2.
So to put it all together, here's how you'd specify a makefile to use pkg-config to compile a source file named MySource.c into MySource executable, specifying include files and libraries for the gtk2, and libglade2 packages. Note that you need to surround each pkg-config invocation with ` characters.
CFLAGS=`pkg-config --cflags libglade-2.0` `pkg-config --cflags gtk+-2.0`
LIBS=`pkg-config --libs libglade-2.0` `pkg-config --libs gtk+-2.0`
OBJECTS=MySource.o
# Comment the next line to create a version without debugging
LDFLAGS=-g
MySource: $(OBJECTS)
gcc $(LDFLAGS) -o $@ $(OBJECTS) $(LIBS)
MySource.o: MySource.c
gcc -Wall -c $^ $(CFLAGS)
And that's it. Just name the above file "makefile" (in the same directory as MySource,c), and type "make" at the terminal. This is a hell of a lot less painful than dealing with an IDE that isn't quite up to the task of hassle-free development.
Bookmarks