gtk in cygwin

J

johnmmcparland

Hi all,

I am doing some C / C++ programming in cygwin and I notice when I add
something to my path then try to compile, the gcc / g++ compiler
cannot find some files, even though they are in the directory I may
have just added to my path.

For example I have copied the example program from http://www.gtk.org/tutorial/c39.html
and when I compiled it, the compiler couldn't find gtk/gtk.h.

I thought to solve this I would have to add the path to gtk/gtk.h to
my path and so I did;
PATH=$PATH:/usr/include/gtk-2.0

then I compiled again and while it found gtk.h it could not find a lot
of other gtk headers, such as gtktext.h. However this and the other
files which were not found are also in /usr/include/gtk-2.0 and they
are included as <gtk/gtktext.h>.

I'm guessing that my path has not been set right but I'm fumbling in
the dark. If someone could help it would be greatly appreciated.

John
 
V

Victor Bazarov

johnmmcparland said:
I am doing some C / C++ programming in cygwin and I notice when I add
something to my path then try to compile, the gcc / g++ compiler
cannot [..]

I'm guessing that my path has not been set right but I'm fumbling in
the dark. If someone could help it would be greatly appreciated.

Somebody in 'gnu.g++.help' should be able to.
 
B

bjeremy

johnmmcparland said:
Hi all,

I am doing some C / C++ programming in cygwin and I notice when I add
something to my path then try to compile, the gcc / g++ compiler
cannot find some files, even though they are in the directory I may
have just added to my path.

For example I have copied the example program from http://www.gtk.org/tutorial/c39.html
and when I compiled it, the compiler couldn't find gtk/gtk.h.

I thought to solve this I would have to add the path to gtk/gtk.h to
my path and so I did;


then I compiled again and while it found gtk.h it could not find a lot
of other gtk headers, such as gtktext.h. However this and the other
files which were not found are also in /usr/include/gtk-2.0 and they
are included as <gtk/gtktext.h>.

I'm guessing that my path has not been set right but I'm fumbling in
the dark. If someone could help it would be greatly appreciated.

John

Not sure if this helps, but if you are trying to compile from an
application outside a Cygwin shell (i.e. Eclipse or other IDE), you
may need to add the path to your windows environment variables...
You'll need to add the to the windows directory where the executable
lives, not the directory structure used by Cygwin.
 
J

James Kanze

I am doing some C / C++ programming in cygwin and I notice when I add
something to my path then try to compile, the gcc / g++ compiler
cannot find some files, even though they are in the directory I may
have just added to my path.
For example I have copied the example program fromhttp://www.gtk.org/tutorial/c39.html
and when I compiled it, the compiler couldn't find gtk/gtk.h.
I thought to solve this I would have to add the path to gtk/gtk.h to
my path and so I did;

then I compiled again and while it found gtk.h it could not find a lot
of other gtk headers, such as gtktext.h. However this and the other
files which were not found are also in /usr/include/gtk-2.0 and they
are included as <gtk/gtktext.h>.
I'm guessing that my path has not been set right but I'm fumbling in
the dark. If someone could help it would be greatly appreciated.

This is really somewhat platform specific, but on Unix and
Windows platforms, $PATH (or %PATH% in a Windows shell)
specifies where the system should look for executables (and
dynamically linked objects under Windows), and has nothing to do
with include files. The de facto standard for specifying
include file paths is the compiler option -I (or /I under
Windows); depending on the compiler you may or may not need a
space between the -I and the path name. (I think g++ accepts it
both ways, but other Unix compilers don't accept the space.)
Some compilers will also have a special environment variable
which will be added to the list---I think $INCLUDE (or
%INCLUDE%, if you're using the standard Windows shell) works
with VC++, for example---but this is not universal. The normal
procedure is to add the -I options to the flags passed to the
compiler in the makefile.

Note that having done this, you may need something similar for
the libraries. Here, systems differ more; under Unix, it is
generally possible to specify library paths using a -L option,
but I don't think this works under Windows. A more portable
solution is to just specify the library path completely.f

Finally, if the library is in fact a dynamically loaded object
(.DLL or .so), you might have to add something to a path
variable so that the executable will find it: Unix generally
uses a separate variable, LD_LIBRARY_PATH (and puts such objects
in a separate directory), whereas Windows just uses the standard
$PATH (and puts such objects in the same directory as the
executables).
 
L

Lionel B

Hi all,

I am doing some C / C++ programming in cygwin and I notice when I add
something to my path then try to compile, the gcc / g++ compiler cannot
find some files, even though they are in the directory I may have just
added to my path.

For example I have copied the example program from
http://www.gtk.org/tutorial/c39.html and when I compiled it, the
compiler couldn't find gtk/gtk.h.

I thought to solve this I would have to add the path to gtk/gtk.h to my
path and so I did;


then I compiled again and while it found gtk.h it could not find a lot
of other gtk headers, such as gtktext.h. However this and the other
files which were not found are also in /usr/include/gtk-2.0 and they are
included as <gtk/gtktext.h>.

I'm guessing that my path has not been set right but I'm fumbling in the
dark. If someone could help it would be greatly appreciated.

Don't know about Cygwin, but on other unix-like systems it is common to
use a utility called pkg-config:

http://pkgconfig.freedesktop.org/wiki/

to set up compiler/linker options for (amongst other libraries) gtk+. For
instance on my (linux) system, I get:

$ pkg-config --cflags gtk+
-I/usr/include/gtk-1.2 -I/usr/X11R6/include -I/usr/include/glib-1.2 -I/usr/lib64/glib/include

$ pkg-config --libs gtk+
-L/usr/X11R6/lib64 -lgtk -lgdk -lXi -lXext -lX11 -lm -lglib

so you can compile a program accessing gtk+ with something like:

g++ ... `pkg-config --cflags gtk+` ...

(note the back quotes) and link with:

g++ ... `pkg-config --libs gtk+` ...

(you may need to specify gtk+-2.0 if you have multiple versions of gtk+)

See also:

http://www.gtk.org/faq/#AEN409

HTH,
 
M

Mumia W.

Hi all,

I am doing some C / C++ programming in cygwin and I notice when I add
something to my path then try to compile, the gcc / g++ compiler
cannot find some files, even though they are in the directory I may
have just added to my path.

For example I have copied the example program from http://www.gtk.org/tutorial/c39.html
and when I compiled it, the compiler couldn't find gtk/gtk.h.

I thought to solve this I would have to add the path to gtk/gtk.h to
my path and so I did;


then I compiled again and while it found gtk.h it could not find a lot
of other gtk headers, such as gtktext.h. However this and the other
files which were not found are also in /usr/include/gtk-2.0 and they
are included as <gtk/gtktext.h>.

I'm guessing that my path has not been set right but I'm fumbling in
the dark. If someone could help it would be greatly appreciated.

John

You would have to add /usr/include/gtk-2.0 to the compiler's include
path. For g++, that might be done by setting the -I option, e.g.:

g++ -I /usr/include/gtk-2.0 myprogram.cc -o myprogram

For other compiler's, the methods will be different. You should ask in a
newsgroup dedicated to your compiler.
 
J

Jim Langston

johnmmcparland said:
Hi all,

I am doing some C / C++ programming in cygwin and I notice when I add
something to my path then try to compile, the gcc / g++ compiler
cannot find some files, even though they are in the directory I may
have just added to my path.

For example I have copied the example program from
http://www.gtk.org/tutorial/c39.html
and when I compiled it, the compiler couldn't find gtk/gtk.h.

I thought to solve this I would have to add the path to gtk/gtk.h to
my path and so I did;


then I compiled again and while it found gtk.h it could not find a lot
of other gtk headers, such as gtktext.h. However this and the other
files which were not found are also in /usr/include/gtk-2.0 and they
are included as <gtk/gtktext.h>.

I'm guessing that my path has not been set right but I'm fumbling in
the dark. If someone could help it would be greatly appreciated.

Off topic, but I believe it's because you're using a colon : instead of a
semi-colon ;

Try changing from
PATH=$PATH:/usr/include/gtk-2.0
to
PATH=$PATH;/usr/include/gtk-2.0
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top