| | |
Installing GTK and MinGW in Windows
![]() |
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:
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:
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
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.

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:
C Syntax (Toggle Plain Text)
gcc something.c -o something.exe -std=c89 -Wall `pkg-config gtk+-2.0 --cflags --libs`
C Syntax (Toggle Plain Text)
all: /mingw/bin/redir -e errors.txt gcc something.c -o something.exe -std=c89 -Wall `pkg-config gtk+-2.0 --cflags --libs`
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
C Syntax (Toggle Plain Text)
pkg-config gtk+-2.0 --cflags --libs
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.
Knowledge is regarded by the fool as ignorance, and the things that are profitable are to him hurtful. He liveth in death. -- Thoth the Atlantean
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:
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
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:
C Syntax (Toggle Plain Text)
http://ftp.gnome.org/pub/gnome/binaries/win32/atk/1.12/atk-1.12.3.zip http://ftp.gnome.org/pub/gnome/binaries/win32/atk/1.12/atk-dev-1.12.3.zip http://www.gimp.org/%7Etml/gimp/win32/gettext-0.14.5.zip http://www.gimp.org/%7Etml/gimp/win32/gettext-dev-0.14.5.zip http://ftp.gnome.org/pub/gnome/binaries/win32/glib/2.12/glib-2.12.13.zip http://ftp.gnome.org/pub/gnome/binaries/win32/glib/2.12/glib-dev-2.12.13.zip http://ftp.gnome.org/pub/gnome/binaries/win32/gtk+/2.10/gtk+-2.10.14.zip http://ftp.gnome.org/pub/gnome/binaries/win32/gtk+/2.10/gtk+-dev-2.10.14.zip http://gnuwin32.sourceforge.net/downlinks/jpeg-bin-zip.php http://gnuwin32.sourceforge.net/downlinks/jpeg-lib-zip.php http://www.gimp.org/%7Etml/gimp/win32/libiconv-1.9.1.bin.woe32.zip http://gnuwin32.sourceforge.net/downlinks/libpng-bin-zip.php http://gnuwin32.sourceforge.net/downlinks/libpng-lib-zip.php http://ftp.gnome.org/pub/gnome/binaries/win32/pango/1.16/pango-1.16.4.zip http://ftp.gnome.org/pub/gnome/binaries/win32/pango/1.16/pango-dev-1.16.4.zip http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/cairo-1.4.8.zip http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/cairo-dev-1.4.8.zip http://www.gimp.org/%7Etml/gimp/win32/pkg-config-0.20.zip http://gnuwin32.sourceforge.net/downlinks/tiff-bin-zip.php http://gnuwin32.sourceforge.net/downlinks/tiff-lib-zip.php 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
Knowledge is regarded by the fool as ignorance, and the things that are profitable are to him hurtful. He liveth in death. -- Thoth the Atlantean
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.
Knowledge is regarded by the fool as ignorance, and the things that are profitable are to him hurtful. He liveth in death. -- Thoth the Atlantean
Last edited by Ancient Dragon; Aug 14th, 2007 at 6:46 pm.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
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...
Knowledge is regarded by the fool as ignorance, and the things that are profitable are to him hurtful. He liveth in death. -- Thoth the Atlantean
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.
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/
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.
•
•
•
•
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)
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/
dwk
Seek and ye shall find.
"Only those who will risk going too far can possibly find out how far one can go."
-- TS Eliot.
"I have not failed. I've just found 10,000 ways that won't work."
-- Thomas Alva Edison
"The only real mistake is the one from which we learn nothing."
-- John Powell
Seek and ye shall find.
"Only those who will risk going too far can possibly find out how far one can go."
-- TS Eliot.
"I have not failed. I've just found 10,000 ways that won't work."
-- Thomas Alva Edison
"The only real mistake is the one from which we learn nothing."
-- John Powell
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.
Knowledge is regarded by the fool as ignorance, and the things that are profitable are to him hurtful. He liveth in death. -- Thoth the Atlantean
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.
Knowledge is regarded by the fool as ignorance, and the things that are profitable are to him hurtful. He liveth in death. -- Thoth the Atlantean
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.
Knowledge is regarded by the fool as ignorance, and the things that are profitable are to him hurtful. He liveth in death. -- Thoth the Atlantean
![]() |
Similar Threads
- Windows Explorer Crashing (Viruses, Spyware and other Nasties)
- installing linux over troubled windows (*nix Software)
- Windows XP starts only in Safe Mode (Windows NT / 2000 / XP)
- Installing mac as primary os on a windows pc (Windows NT / 2000 / XP)
- New Motherboard & Pre-installed Windows XP (Windows NT / 2000 / XP)
- Computer freezes when i try to install windows XP (Windows NT / 2000 / XP)
- after installing suse pro 9.1, windows ntldr missing (*nix Software)
- A7N8X; installing dual-channel RAM (Windows NT / 2000 / XP)
Other Threads in the C Forum
- Previous Thread: How do I eliminate some characters from the end of a string?
- Next Thread: conditionally linking in Makefile
| Thread Tools | Search this Thread |
#include * adobe ansi array arrays asterisks binarysearch centimeter changingto char character cm convert copyimagefile cprogramme creafecopyofanytypeoffileinc createprocess() database dynamic execv feet fgets file floatingpointvalidation fork function getlogicaldrivestrin givemetehcodez global grade gtkwinlinux hacking histogram inches include incrementoperators infiniteloop input interest intmain() iso kernel keyboard kilometer km license linked linkedlist linux locate looping lowest matrix meter microsoft number oddnumber open opendocumentformat openwebfoundation owf pattern pdf performance pointer posix power probleminc process program programming radix recursion recv recvblocked research reversing segmentationfault sequential single socket socketprograming socketprogramming standard strchr string suggestions systemcall test threads turboc unix urboc user variable voidmain() wab whythiscodecausesegmentationfault windowsapi






