943,938 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 19743
  • C RSS
You are currently viewing page 1 of this multi-page discussion thread
Aug 14th, 2007
0

Installing GTK and MinGW in Windows

Expand Post »
I created this thread to have a common place to discuss these issues. GTK is a cross-platform non-commercial graphical user interface for C, now there are these snippets here using GTK http://www.daniweb.com/code/snippet744.html and http://www.daniweb.com/code/snippet737.html but i hope that there would be more

Maybe the best howto is this http://www.ibiblio.org/apollo/WinGtkHowto.html I though don't recommend using glade. Also, there is an easier way to compile GTK programs:
  1. gcc something.c -o something.exe -std=c89 -Wall `pkg-config gtk+-2.0 --cflags --libs`
It is again because of the braindead nature of many windows things, that the pkg-config part between the backquotes must be last in command line, though in gcc it doesn't suppose to matter where in the command line something is. You can also write a simple makefile:
  1. all:
  2. /mingw/bin/redir -e errors.txt gcc something.c -o something.exe -std=c89 -Wall `pkg-config gtk+-2.0 --cflags --libs`
and then run "make" in the directory where your code is, to compile. There, the redir stuff is just to redirect the errors to errors.txt, you can do without it, but it's useful sometimes. The reason why the msys is necessary, is because of the braindead nature of windows things, as well. It is just that the windows shell cannot anyhow do the simple thing what these backquotes mean, ie to add the output of the command in backquotes, to command line. Instead of msys you may also use z shell http://zsh.dotsrc.org in windows. Other good feature of the bash-like shell is the tab expansion, which is that you can get a full file or directory name after typing only a part of it, by pressing tab.

How to compile GTK programs with IDE-s like dev-c++, would likely be for you to figure out, but dev-c++ has mingw, and once it also had a package system, which may help to install GTK more easily. But without using bash-like shell, at least i never succeeded to use backquotes in the command line. But the thing is really simple, all you need is to add to compiler options or such, everything which
  1. pkg-config gtk+-2.0 --cflags --libs
outputs. And unless you move GTK libraries to some other place, this should work all the time.

If you want to use mingw without dev-c++ or msys, you should add the /mingw/bin directory to the path, changing start > settings > control panel > system > advanced > environment variables > local variables > PATH. The paths there are separated by semicolon. Now when the gcc says "no input files", then your compiler works.

Installing the zip files is really easy. Download all these zip files to your /mingw directory. To do this easier, you may write a list there, and when you have wget, simply run wget -i list in your /mingw directory. Now provided that you have infozip http://www.info-zip.org, you can simply run unzip *.zip in your /mingw directory. I though use 7zip in windows for all kind of archives.

Don't worry about extracting the archives all under the same directory. All that "installing" is really copying, no configuring is done there. Also the mingw installer doesn't do much, it just extracts the archives under the directory you wish. It is also possible to install mingw by downloading separate archives the same way as gtk, these archives are listed in mingw wiki, all you really need is gcc, binutils, and "mingw-runtime", which is the package that contains all the mingw libraries and header files. The only thing which you have to remember, is that all your archives were roughly from the same release, as they otherwise may not well work together. You can safely overwrite the old files by extracting archives of the newer versions, because for the above reasons such overwriting would not damage anything.
Last edited by TkTkorrovi; Aug 14th, 2007 at 2:10 pm.
Similar Threads
Reputation Points: 85
Solved Threads: 13
Junior Poster
TkTkorrovi is offline Offline
170 posts
since Mar 2005
Aug 14th, 2007
0

Re: Intalling GTK and MinGW in Windows

Ohh, mistake in the title, can someone repair it? To make things easier for you, proceed like this:

1. Download mingw at http://downloads.sourceforge.net/min...6&big_mirror=1 and install it in the directory /mingw

2. Download msys at http://downloads.sourceforge.net/min...7&big_mirror=1 and install it, saying that mingw is installed in /mingw

3. Download unzip at ftp://ftp.info-zip.org/pub/infozip/WIN32/unz552xn.exe and ftp://ftp.info-zip.org/pub/infozip/WIN32/unz552dn.zip and install it in /mingw/bin

4. Download wget at http://users.ugent.be/~bpuype/cgi-bi...=wget/wget.exe and install it in /mingw/bin

5. Add /mingw/bin to PATH

6. Create a text file called list in your /mingw directory, and add the following list there:
  1. http://ftp.gnome.org/pub/gnome/binaries/win32/atk/1.12/atk-1.12.3.zip
  2. http://ftp.gnome.org/pub/gnome/binaries/win32/atk/1.12/atk-dev-1.12.3.zip
  3. http://www.gimp.org/%7Etml/gimp/win32/gettext-0.14.5.zip
  4. http://www.gimp.org/%7Etml/gimp/win32/gettext-dev-0.14.5.zip
  5. http://ftp.gnome.org/pub/gnome/binaries/win32/glib/2.12/glib-2.12.13.zip
  6. http://ftp.gnome.org/pub/gnome/binaries/win32/glib/2.12/glib-dev-2.12.13.zip
  7. http://ftp.gnome.org/pub/gnome/binaries/win32/gtk+/2.10/gtk+-2.10.14.zip
  8. http://ftp.gnome.org/pub/gnome/binaries/win32/gtk+/2.10/gtk+-dev-2.10.14.zip
  9. http://gnuwin32.sourceforge.net/downlinks/jpeg-bin-zip.php
  10. http://gnuwin32.sourceforge.net/downlinks/jpeg-lib-zip.php
  11. http://www.gimp.org/%7Etml/gimp/win32/libiconv-1.9.1.bin.woe32.zip
  12. http://gnuwin32.sourceforge.net/downlinks/libpng-bin-zip.php
  13. http://gnuwin32.sourceforge.net/downlinks/libpng-lib-zip.php
  14. http://ftp.gnome.org/pub/gnome/binaries/win32/pango/1.16/pango-1.16.4.zip
  15. http://ftp.gnome.org/pub/gnome/binaries/win32/pango/1.16/pango-dev-1.16.4.zip
  16. http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/cairo-1.4.8.zip
  17. http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/cairo-dev-1.4.8.zip
  18. http://www.gimp.org/%7Etml/gimp/win32/pkg-config-0.20.zip
  19. http://gnuwin32.sourceforge.net/downlinks/tiff-bin-zip.php
  20. http://gnuwin32.sourceforge.net/downlinks/tiff-lib-zip.php
  21. http://www.zlib.net/zlib123-dll.zip

7. Make sure that you are in the directory /mingw, the only reasonable way to do that, is going there with windows cmd shell, remember that windows explorer doesn't change directory in the shell!

8. Run wget -i list

9. Run unzip *.zip

10. Open msys, go to the directory where your code is, use absolute path while changing directory if necessary, and compile.

That's all
Reputation Points: 85
Solved Threads: 13
Junior Poster
TkTkorrovi is offline Offline
170 posts
since Mar 2005
Aug 14th, 2007
0

Re: Intalling GTK and MinGW in Windows

Hmm, but what is the advantage of using this over say QT which I understand is also cross platform?

Or say wxWidgets? Sell it to me.
Last edited by iamthwee; Aug 14th, 2007 at 6:17 pm.
Featured Poster
Reputation Points: 1536
Solved Threads: 431
Posting Expert
iamthwee is offline Offline
5,865 posts
since Aug 2005
Aug 14th, 2007
0

Re: Intalling GTK and MinGW in Windows

The biggest advantage of GTK over QT and wxwidgets is that GTK is *non-commercial*, which means the most free, and the least problems with licenses also when developing the commercial applications. Therefore GTK is the best joice, it is also much more widespread than wxwidgets, and wxwidgets as much as i know, is not a completely independent api, but makes you to use features from the platform where you compile. QT is also only for c++, while GTK is for c, and can therefore be used both from c and c++. Otherwise GTK and QT are very similar.
Last edited by TkTkorrovi; Aug 14th, 2007 at 6:24 pm.
Reputation Points: 85
Solved Threads: 13
Junior Poster
TkTkorrovi is offline Offline
170 posts
since Mar 2005
Aug 14th, 2007
0

Re: Intalling GTK and MinGW in Windows

Click to Expand / Collapse  Quote originally posted by TkTkorrovi ...
Ohh, mistake in the title, can someone repair it?
Fixed -- but next time you should use the Flag Bad Post button to make such a request easy for one of the mods to see.
Last edited by Ancient Dragon; Aug 14th, 2007 at 6:46 pm.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,953 posts
since Aug 2005
Aug 15th, 2007
0

Re: Installing GTK and MinGW in Windows

OK, to be more exact, and i must be very exact, Qt is developed by Trolltech, but wxwidgets knowingly not by any company. But licenses of both are not a clear LGPL, which is the license of GTK... Also, wxwidgets is for c++, so both of them are not alternatives for these who want to use c. And considring that this forum is about c, there are so far no other cross-platform GUI libraries to choose, than GTK... Still there are likely others, but these are then not much widespread at all. One may say there is SDL, but this is only a graphics library, with no GUI (though there is one which would hardly ever satisfy anyone), and even no windows, this is certainly not something even close to a universal graphics library...
Reputation Points: 85
Solved Threads: 13
Junior Poster
TkTkorrovi is offline Offline
170 posts
since Mar 2005
Aug 21st, 2007
0

Re: Installing GTK and MinGW in Windows

Qt is released under two licenses. http://trolltech.com/company/model
It's released under the GNU GPL (not the LGPL), which means that it's under the copyleft and your program which uses Qt must also be released under the GPL. If you want to develop commercial applications with Qt, you have to obtain a commercial license from TrollTech.

The LGPL (Library General Public License, formerly Lesser GPL) is what most libraries are released under: you can use the library for any purpose (i.e., link it with commercial programs, or programs with other licenses); but any changes to the program itself are still under the GPL. This means that changes to GTK+ must be released under the LGPL as well.

Quote ...
One may say there is SDL, but this is only a graphics library, with no GUI (though there is one which would hardly ever satisfy anyone)
There are several good SDL GUI libraries, some of which are listed in the link at the end of this post, some of which are here: http://libsdl.org/libraries.php?orde...me=&perpage=-1 (search for GUI, but not with the built-in search function, as it only searches names; use your browser's search).

I've recently looked into some of them. Quite a few are written in C, which was one thing I was looking for. I eventually decided I would write my own GUI library, but not because there were no good ones out there.

And even if a library is written in C++, you can usually use it in C, though it might be a bit of a hassle to do so.

Here's an extensive, if hard-to-read, list of GUI libraries: http://www.free-soft.org/guitool/
Reputation Points: 185
Solved Threads: 28
Posting Whiz in Training
dwks is offline Offline
269 posts
since Nov 2005
Aug 21st, 2007
0

Re: Installing GTK and MinGW in Windows

Yes but none of these is used very widely, and is not near as complete as GTK... It is one general knowledge about using software, that it's not worth to use any minimal solutions, but to use a more complicated one instead, and use only simple things from it. Because when the need may be, you would have all the facilities you need, not that your simple thing just cannot do something. And as i said, these are not very widely used, which also means that the library you use may go out of use, which happens when no one maintains it any more, making it to work together with all the possible newer things. Then you just jump from one library to another, this is not simple any more, and may still end up by using something decent... I know it's a hard decision to start to use GTK, because as a whole it is terribly complex, but you don't have to use everything, for simple things it's not so terribly difficult at all. But it's a good and decent thing, which works on every platform, mostly without *any* changes, and enables to do all the things you may ever need for graphics and graphical user interface, whenever the need may be. And also, GTK has a lot of users, so much easier to find people who may help, SDL has also a lot of users, most writing only games though, but its many GUI-s have not so many users. I don't argue that GTK is perfect, though neither is QT or others... Long function names like pango_layout_set_font_description are impossible for anyone to remember, though they mostly do the most simple things. But there is nothing to do, we should accept what there is, and what is most widely used, otherwise GTK is a quite good library, and not very difficult at all to use. At least it is somewhat easier than windows api, which i can say because i have used both.
Last edited by TkTkorrovi; Aug 21st, 2007 at 5:33 pm.
Reputation Points: 85
Solved Threads: 13
Junior Poster
TkTkorrovi is offline Offline
170 posts
since Mar 2005
Aug 21st, 2007
0

Re: Installing GTK and MinGW in Windows

BTW, what concerns SDL, it's also not so modern low level graphics library any more. Cairo http://cairographics.org is much newer, and enables to draw antialiased text and graphics, also transparent, it's also not very complicated at all. Cairo is a part of GTK, and is its low-level engine through which the graphics in GTK is done. After GTK started to use cairo, the quality of all GTK applications improved tremendously, which i have seen myself in linux. The gnome desktop, web browser, all the graphics in linux became, how my impression was, better than that of windows xp. But unfortunately, there is likely yet no way to use cairo separately, or even to use it directly from gtk. Or, when there is a way, then it likely doesn't work very well yet, at least not so well that they would consider cairo functions as a part of the api, and also did include them into official api reference.
Reputation Points: 85
Solved Threads: 13
Junior Poster
TkTkorrovi is offline Offline
170 posts
since Mar 2005
Aug 22nd, 2007
0

Re: Installing GTK and MinGW in Windows

It is the nature of programming, that there always appear some floating pumpkins everywhere... Therefore it's good to go with some serious development, this as a rule always ends with the right solutions. And GTK is one such thing, whatever it would be some years from now, it would be the right thing, and if anything there is not good yet, this will certainly be improved. I'm also the most sure, that one day there would be a simpler version of GTK, where the unnecessary things are eliminated, this is the way how the things develop. In fact, there even was a thing called easygtk, but this is not maintained any more, likely the time for such didn't come yet.
Reputation Points: 85
Solved Threads: 13
Junior Poster
TkTkorrovi is offline Offline
170 posts
since Mar 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: How do I eliminate some characters from the end of a string?
Next Thread in C Forum Timeline: conditionally linking in Makefile





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC