D
Dave Farrance
What's the correct way to find the include directories and link
libraries when compiling with gnu c++ ?
I decided that I'd like to try out line-drawing using the GTK toolkit,
so I copied the line drawing examples from this tutorial page:
http://www.gtkmm.org/tutorial/sec-drawingarea.html
I then tried to compile it with c++ on Mandrake Linux, and spent ages
resolving the dependencies.
I ran the compiler, looked at the first complaint about a header file
that it couldn't include, used the "locate" command to find it on my
machine, and if it wasn't found, search for the package containing that
file to be downloaded, and then add that directory as a compiler include
directive. This had to be repeated several times.
Then the linking. At each complaint about an unresolved function, I
tried to guess the library that was required from the name of the
function, or from the names of the previously worked out include files,
and from the names of libraries in the /usr/lib directory. I usually
stumbled onto the correct library after a few attempts in each case.
After all that work, my makefile ended up looking like this:
gtktest : gtktest.cc
c++ gtktest.cc -o gtktest \
-I/usr/include/gtk-1.2 -I/usr/lib/gtkmm/include \
-I/usr/include/glib-1.2 -I/usr/lib/glib/include \
-I/usr/include/sigc++-1.0 \
-lgtkmm -lsigc -lgdkmm -lpthread
That was just to try out a tutorial. Surely it shouldn't be that hard?
Am I going about this the wrong way?
libraries when compiling with gnu c++ ?
I decided that I'd like to try out line-drawing using the GTK toolkit,
so I copied the line drawing examples from this tutorial page:
http://www.gtkmm.org/tutorial/sec-drawingarea.html
I then tried to compile it with c++ on Mandrake Linux, and spent ages
resolving the dependencies.
I ran the compiler, looked at the first complaint about a header file
that it couldn't include, used the "locate" command to find it on my
machine, and if it wasn't found, search for the package containing that
file to be downloaded, and then add that directory as a compiler include
directive. This had to be repeated several times.
Then the linking. At each complaint about an unresolved function, I
tried to guess the library that was required from the name of the
function, or from the names of the previously worked out include files,
and from the names of libraries in the /usr/lib directory. I usually
stumbled onto the correct library after a few attempts in each case.
After all that work, my makefile ended up looking like this:
gtktest : gtktest.cc
c++ gtktest.cc -o gtktest \
-I/usr/include/gtk-1.2 -I/usr/lib/gtkmm/include \
-I/usr/include/glib-1.2 -I/usr/lib/glib/include \
-I/usr/include/sigc++-1.0 \
-lgtkmm -lsigc -lgdkmm -lpthread
That was just to try out a tutorial. Surely it shouldn't be that hard?
Am I going about this the wrong way?