1,105,534 Community Members

Installing GTK and MinGW in Windows

Member Avatar
TkTkorrovi
Junior Poster
170 posts since Mar 2005
Reputation Points: 69 [?]
Q&As Helped to Solve: 13 [?]
Skill Endorsements: 0 [?]
 
0
 

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:

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:

all:
	/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

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.

Member Avatar
TkTkorrovi
Junior Poster
170 posts since Mar 2005
Reputation Points: 69 [?]
Q&As Helped to Solve: 13 [?]
Skill Endorsements: 0 [?]
 
0
 

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/mingw/MinGW-5.1.3.exe?modtime=1168811236&big_mirror=1 and install it in the directory /mingw

2. Download msys at http://downloads.sourceforge.net/mingw/MSYS-1.0.10.exe?modtime=1079444447&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-bin/fetch.pl?dl=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:

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

Member Avatar
iamthwee
Posting Sage
7,066 posts since Aug 2005
Reputation Points: 1,307 [?]
Q&As Helped to Solve: 595 [?]
Skill Endorsements: 74 [?]
Featured
 
0
 

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.

Member Avatar
TkTkorrovi
Junior Poster
170 posts since Mar 2005
Reputation Points: 69 [?]
Q&As Helped to Solve: 13 [?]
Skill Endorsements: 0 [?]
 
0
 

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.

Member Avatar
Ancient Dragon
Achieved Level 70
27,632 posts since Aug 2005
Reputation Points: 5,232 [?]
Q&As Helped to Solve: 3,037 [?]
Skill Endorsements: 115 [?]
Team Colleague
Featured
Sponsor
 
0
 

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.

Member Avatar
TkTkorrovi
Junior Poster
170 posts since Mar 2005
Reputation Points: 69 [?]
Q&As Helped to Solve: 13 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
dwks
Posting Whiz in Training
269 posts since Nov 2005
Reputation Points: 149 [?]
Q&As Helped to Solve: 28 [?]
Skill Endorsements: 0 [?]
 
0
 

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.

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?order=name&category=-1&completed=0&os=-1&match_name=&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/

Member Avatar
TkTkorrovi
Junior Poster
170 posts since Mar 2005
Reputation Points: 69 [?]
Q&As Helped to Solve: 13 [?]
Skill Endorsements: 0 [?]
 
0
 

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.

Member Avatar
TkTkorrovi
Junior Poster
170 posts since Mar 2005
Reputation Points: 69 [?]
Q&As Helped to Solve: 13 [?]
Skill Endorsements: 0 [?]
 
0
 

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.

Member Avatar
TkTkorrovi
Junior Poster
170 posts since Mar 2005
Reputation Points: 69 [?]
Q&As Helped to Solve: 13 [?]
Skill Endorsements: 0 [?]
 
0
 

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.

Member Avatar
TkTkorrovi
Junior Poster
170 posts since Mar 2005
Reputation Points: 69 [?]
Q&As Helped to Solve: 13 [?]
Skill Endorsements: 0 [?]
 
0
 

You can also compile gtk programs both in linux and in windows cmd console, like this:

pkg-config gtk+-2.0 --cflags --libs | xargs gcc something.c -o something.exe

if you have xargs, which is in the findutils package of gnuwin32. This though likely doesn't work in any IDE. One good thing to remember about windows console is that clicking the mouse right button adds the content of the clipboard to the command line, and selecting text and pressing enter, copies the selected text into the clipboard.

Member Avatar
TkTkorrovi
Junior Poster
170 posts since Mar 2005
Reputation Points: 69 [?]
Q&As Helped to Solve: 13 [?]
Skill Endorsements: 0 [?]
 
0
 

Look you guys really drive me nuts with your talk about other graphics libraries and gui toolkits. A good library for graphics is opengl, it's cross-platform, and it's the best when you want the most access to the graphics hardware. But it only makes sense to learn it, when the only thing what you want to do is writing 3d games. SDL is *not* good, it does not enable the best graphics quality, good hardware acceleration, and is not the most modern graphics library either. And so are not good any gui libraries based on sdl. The same can be said about windows gdi, xlib and anything such. In these, the things like graphics contexts and such are a terribly old and totally outdated concept. A modern open source and cross-platform graphics library is cairo, its functions are such that they easily enable to send commands to the graphics hardware, and therefore enable graphics acceleration whenever possible. Whether such graphics acceleration is done, of course depends on implementation and not on the graphics interface, but cairo enables it, so knowing it is all what is necessary for 2d graphics. I said it's the best to go with some serious thing. Maybe they are really going to totally replace gdk in gtk with cairo, in newer version almost all the widgets are rendered with cairo and not with gdk. This would not be bad, when they make cairo to work directly through opengl, and not through xlib, the whole graphics in linux at least would be significantly faster and higher quality.

Member Avatar
Hamrick
Posting Whiz
322 posts since Jun 2007
Reputation Points: 150 [?]
Q&As Helped to Solve: 35 [?]
Skill Endorsements: 0 [?]
 
0
 

Look you guys really drive me nuts with your talk about other graphics libraries and gui toolkits.

That sounds pretty narrow minded. You found something you like, and other people have to use it too because you won't tolerate listening to other suggestions? Ignoring technical details, that attitude makes me less inclined to listen to your advice. People who refuse to keep an open mind don't often make good choices.

Member Avatar
TkTkorrovi
Junior Poster
170 posts since Mar 2005
Reputation Points: 69 [?]
Q&As Helped to Solve: 13 [?]
Skill Endorsements: 0 [?]
 
0
 

Hamrick, you are totally wrong, and the only thing which i can do is to hope that you would once understand that. If you care to read, i substantiate what i say, and why i say that, so the way to argue is not talking bad about me, but criticizing my arguments. If you prove them wrong, then i also agree that i was wrong, but this is what you didn't talk about, and likely also didn't think about, at all.

And finally, this *thread* is about gtk. Then people come here and talk about other libraries, when they well could create separate threads about these, and write there why they think they are good for. But ok, if people want to talk about gtk compared to other libraries, i accept their wish and explain the advantages of gtk. But then some come to accuse me that i'm narrow-minded and talk only about something which i like. The reason is not that i like it, i want to find out what library is the best to use, based on rational arguments, but anyway concerning such accusations, somewhere is the limit, peoples.

Member Avatar
Hamrick
Posting Whiz
322 posts since Jun 2007
Reputation Points: 150 [?]
Q&As Helped to Solve: 35 [?]
Skill Endorsements: 0 [?]
 
0
 

Hamrick, you are totally wrong

It's impossible to be totally wrong. :D

If you prove them wrong, then i also agree that i was wrong, but this is what you didn't talk about, and likely also didn't think about, at all.

I'm not trying to prove you wrong. In the absence of technical arguments, I made that clear before too, your attitude toward alternatives is exactly what I called it: narrow minded. Whether you actually feel that way is irrelevant because the only thing that matters is how you present yourself, not how you really are behind the keyboard.

But then some come to accuse me that i'm narrow-minded and talk only about something which i like.

I think you missed the order of events. Your narrow minded attitude started before my accusation because my accusation quoted what I felt was narrow minded, and my accusation was the first one on this thread.

but anyway concerning such accusations, somewhere is the limit, peoples.

And for you the limit is 1? Because including me, on this thread, there's 1 and only 1. ;) If you don't like criticism of your attitude, you shouldn't present yourself as a know-it-all.

I'm sorry for hijacking the thread. I just wanted to let you know what I thought.

Member Avatar
TkTkorrovi
Junior Poster
170 posts since Mar 2005
Reputation Points: 69 [?]
Q&As Helped to Solve: 13 [?]
Skill Endorsements: 0 [?]
 
0
 

> Ignoring technical details, that attitude makes me less inclined to listen to your advice.

> In the absence of technical arguments, I made that clear before too, your attitude toward alternatives is exactly what I called it: narrow minded.

Look, you explain in your own words perfectly the mistake you do -- you draw things out of context.

There are several methods of demagogy, and one of these is to tell only half of the story, and ignore the rest. This is useful for demagogy because the things are often opposite to each other, and one opposite without another easily enables to exaggerate something and to give it a completely different meaning, like someone wants it to see.

Member Avatar
Hamrick
Posting Whiz
322 posts since Jun 2007
Reputation Points: 150 [?]
Q&As Helped to Solve: 35 [?]
Skill Endorsements: 0 [?]
 
0
 

It's not a mistake. If I'm not intimately familiar with the details, I can't confirm or deny them. But if your attitude suggests that you don't have an open mind, I can use that to infer that your idea of "better" is flawed and develop a suitable amount of skepticism for your arguments.

Member Avatar
TkTkorrovi
Junior Poster
170 posts since Mar 2005
Reputation Points: 69 [?]
Q&As Helped to Solve: 13 [?]
Skill Endorsements: 0 [?]
 
0
 

You are free to think or guess what you want, but why do you write it here to everyone?

Member Avatar
Hamrick
Posting Whiz
322 posts since Jun 2007
Reputation Points: 150 [?]
Q&As Helped to Solve: 35 [?]
Skill Endorsements: 0 [?]
 
0
 

I thought I'd try to help you improve your appearance. But I guess you don't care. I won't bother you again.

Member Avatar
TkTkorrovi
Junior Poster
170 posts since Mar 2005
Reputation Points: 69 [?]
Q&As Helped to Solve: 13 [?]
Skill Endorsements: 0 [?]
 
0
 

You didn't seem to care so much about me, but ok, it's enough if you try to improve your appearance.

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article