This is highly interesting.
Sorry for this long post, but it could save a lot more.
Ok, I am also a linux fan since 1998. Coincidence? This is when I realized I would have to throw 150 bucks every 3 years just because someone is forcing to do so, anyway...
I much prefer a gui that makes it easier to set compile options, include directories, link libs, etc. than either try (and fail) to remember what all those params mean, or dig around in man files to figure them out. basically the gui saves me time, and I like that.
Good point. pkg-config is what we need. For compilation from command line, or from makefile.
To see apps using pkg-config, check this command
It will output a list of apps using pkg-config. Take one, for example gtk+-2.0.
Now, I want all includes to compile a GTK+ app. Simple:
Code: Select all
$ pkg-config --cflags gtk+-2.0
-DXTHREADS -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/X11R6/include -I/usr/include/atk-1.0 -I/usr/include/pango-1.0 -I/usr/include/freetype2 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include
Isn't this great? Now I want the libs. All. Now.
Code: Select all
$ pkg-config --libs gtk+-2.0
-Wl,--export-dynamic -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangoxft-1.0 -lpangox-1.0 -lpango-1.0 -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0
Wow! all options!
Thus the command line to compile a GTK+ application is simply:
Code: Select all
gcc -Wall `pkg-config --cflags --libs gtk+-2.0` main.c -o myapp
The `pkg-config --cflags --libs gtk+-2.0` instruction will be executed, and the result injected into command. This is dynamic finding of complex infos no-one want to remember. A must.
To make is even more convenient, I am personnaly using a (simple) alias in my .bashrc:
alias cgtk='gcc -Wall `pkg-config --cflags --libs gtk+-2.0` -fomit-frame-pointer -s -O2 -o '
This way, when i want to compile a GTK+ app, all i have to do is:
This is why I am coming to the conclusion that we must integrate Irrlicht into pkg-config.
Code: Select all
$ g++ `pkg-config --cflags --libs irrlicht-1.2` -o example main.cpp
Furthermore, the Hello world makefile you posted above would become
Code: Select all
CPP = g++
INCS = `pkg-config --cflags Irrlicht-1.2`
LIBS = `pkg-config --libs Irrlicht-1.2`
all:
$(CPP) $(LIBS) main.o object.o -o example
$(CPP) -c $(INCS) object.cpp
clean:
rm example
Or something like that.
The classic makefile you posted above can still be used. pkg-config is just an add-on, a convenient tool, widely used.