473,508 Members | 2,460 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Finding include directories and link libraries

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?

--
Dave Farrance
Jul 23 '05 #1
4 1837
Dave Farrance wrote:
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?


for gtk, glib, and friends there exist config executables that
can be used to get the flags for compilation and linking.

e.g.:
c++ `gtk-config --cflags --libs` -o gtktest gtktest.cc
Jul 23 '05 #2
Thomas Maier-Komor <ma******@lpr.no-spam.e-technik.tu-muenchen.de>
wrote:
for gtk, glib, and friends there exist config executables that
can be used to get the flags for compilation and linking.

e.g.:
c++ `gtk-config --cflags --libs` -o gtktest gtktest.cc


Thanks. That gtk-config generates:
-I/usr/include/gtk-1.2 -I/usr/include/glib-1.2 -I/usr/lib/glib/include
-I/usr/X11R6/include -L/usr/X11R6/lib -lgtk -lgdk -rdynamic -lgmodule
-lglib -ldl -lXi -lXext -lX11 -lm

.... which includes three of the five include directories that I needed,
but none of the libraries, unfortunately. It would have saved me some
work, though. I must watch out for these config files.

--
Dave Farrance
Jul 23 '05 #3
Dave Farrance <Da**********@OMiTTHiSyahooANDTHiS.co.uk> wrote in message news:<nh********************************@4ax.com>. ..
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 [snip] -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

[snip]

You are making your life difficult by using gtkmm 1.2 (and GTK+ 1.2).
It's ancient. The newer versions (e.g. 2.6) have far easier API. And
they use pkg-config to make building much easier - see the gtkmm FAQ.
Jul 23 '05 #4
mu*****@murrayc.com (Murray Cumming) wrote:
You are making your life difficult by using gtkmm 1.2 (and GTK+ 1.2).
It's ancient. The newer versions (e.g. 2.6) have far easier API. And
they use pkg-config to make building much easier - see the gtkmm FAQ.


Thanks. I'd used gtkmm 1.2 because that tutorial was the only example
that I found with a websearch on GTK +"line draw".

I searched for that gtkmm FAQ you mentioned, and discovered that
Mandrake Linux had packaged the gtkmm 2.4 documents in a separate RPM.
There's also a substantial tutorial in there as well with a line draw
example that did look cleaner. And pkg-config worked perfectly.

--
Dave Farrance
Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
3533
by: mescaline | last post by:
Hi, Suppose a_file.cpp contains a function a_function() Now to include it in main_file.cpp I just do #include "a_file.cpp" and I'm all set. i recently came across this seemingly roundabout...
4
15033
by: Exits Funnel | last post by:
Hello, I'm slightly confused about when to use parens around #included files and when to use angle brackets. I understand (I think) that the difference is that the compiler will search in its...
27
528
by: Ramesh | last post by:
Hi, I am currently maintaining a legacy code with a very very large code base. I am facing problems with C/C++ files having a lot of un-necessary #includes. On an average every C/C++ file has...
1
1453
by: Rajko | last post by:
PlatformSDK\include vs include Why ?? Why they made two different versions of the same header files. for example comdef.h is shortened in include(no interface GUID definition) while in...
14
2779
by: prasadjoshi124 | last post by:
Hi All, I am writing a small tool which is supposed to fill the filesystem to a specified percent. For, that I need to read how much the file system is full in percent, like the output given...
6
16989
by: =?Utf-8?B?WW9naSBXYXRjaGVy?= | last post by:
Hello, I am using Visual Studio-2003. I created a project to build my library. Since I am using third party libraries as well, I have specified those additional library dependencies in project...
3
2609
by: =?Utf-8?B?VG9kZCBEb2JtZXllcg==?= | last post by:
I am working on developing a program using Visual Studio 2003 but am having problems getting my program to find my GL.h and GLU.h, and I am guessing it will have the same problems trying to link to...
6
1741
by: Ole Nielsby | last post by:
The standard doesn't define this but what conventions do projects use? As I understand it, #include <somelibrary.h> is used for including system headers and those of frameworks such as...
4
4847
by: bobby | last post by:
Hello group, I just wanted to know where are system standard include and libraries directories in Ubuntu? I searched in usr/include and usr/local/include and I could not find any header?!! I...
0
7231
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7133
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
7066
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7504
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5059
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4724
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3214
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3198
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
773
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.