gtk in cygwin

Discussion in 'C++' started by johnmmcparland, Apr 18, 2007.

  1. 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
     
    johnmmcparland, Apr 18, 2007
    #1
    1. Advertising

  2. johnmmcparland wrote:
    > 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.
     
    Victor Bazarov, Apr 18, 2007
    #2
    1. Advertising

  3. johnmmcparland

    bjeremy Guest

    johnmmcparland wrote:
    > 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


    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.
     
    bjeremy, Apr 18, 2007
    #3
  4. johnmmcparland

    James Kanze Guest

    On Apr 18, 2:55 pm, johnmmcparland <>
    wrote:

    > 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;


    > > 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.


    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).

    --
    James Kanze (GABI Software) email:
    Conseils en informatique orientée objet/
    Beratung in objektorientierter Datenverarbeitung
    9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
     
    James Kanze, Apr 19, 2007
    #4
  5. johnmmcparland

    Lionel B Guest

    Re: [OT] gtk in cygwin

    On Wed, 18 Apr 2007 05:55:11 -0700, johnmmcparland wrote:

    > 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.


    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,

    --
    Lionel B
     
    Lionel B, Apr 19, 2007
    #5
  6. johnmmcparland

    Mumia W. Guest

    On 04/18/2007 07:55 AM, johnmmcparland wrote:
    > 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
    >


    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.


    --
    Count the YOYOs:
    http://home.earthlink.net/~mumia.w.18.spam/games_fever/
     
    Mumia W., Apr 19, 2007
    #6
  7. johnmmcparland

    Jim Langston Guest

    "johnmmcparland" <> wrote in message
    news:...
    > 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.


    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
     
    Jim Langston, Apr 19, 2007
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    516
  2. Replies:
    0
    Views:
    458
  3. Replies:
    2
    Views:
    545
  4. Gergely Kontra
    Replies:
    2
    Views:
    271
    Joao Pedrosa
    Jun 18, 2004
  5. Alex Shulgin
    Replies:
    1
    Views:
    194
    thefed
    Nov 21, 2007
Loading...

Share This Page