473,804 Members | 3,037 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 1858
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.n o-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**********@O MiTTHiSyahooAND THiS.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
3555
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 way to do this in 3 steps: 1. Add in main_file.cpp
4
15057
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 standard include directories for files included as <file> but not for those included as "file". It's clear to me then that headers for the standard libraries (eg, iostream) should be included using the '#include <iostream>' form while header...
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 around 150+ .h files included. I find 75% of the files unnecessary and could be removed. Considering the fact that I have a huge code base, I can't manually fix it. Are there any tools that would report un wanted .h files?
1
1467
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 PlatformSDK\include it's full version ?? WHY ?? Can someone please tell me? Thanks. BTW is it ok to put PlatformSDK\include before include ?
14
2823
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 by df -k lopgod10:~/mycrfile # df -k /mnt/mvdg1/vset Filesystem 1K-blocks Used Available Use% Mounted on
6
17031
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 as "Additional Dependencies" under Linker-Input options. Since those libraries are also in different directory, I specified that library path in project as "Additional Library Directories" under Linker-General options. This is where I see some...
3
2640
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 the .lib and .dll files. What do I all need to do to get this to properly compile and link. Here is what I have done so far. Inside my main project directory, I added a folder called "OpenGL" and inside this folder are 3 sub-folders,...
6
1756
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 wxWidgets - and #include "someheader.h"
4
4864
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 appreciate it if you send me the list of the directories the gcc looks for the header files and libraries for compilation in Linux Ubuntu. Also what does it means if we insert sys before a header file like
0
9706
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9579
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10326
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10075
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9143
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7615
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5520
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4295
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2990
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.