PDA

View Full Version : [SOLVED] [ C++ ] How to distribute applications based on GTK framework ?



OpenGuard
October 28th, 2009, 07:04 PM
Platform: Windows

When I create an application in C++, which is based on GTK ( UI ), I don't see any difference, but that's just because of the fact that I've installed it's runtime - once I remove it, I can no longer use my app. Now, what should I do to make my application distributable ( so the user could just double-click and use it, without installing any additional packages ) ? What files do I need to include to be able to achieve this ?

TheBuzzSaw
October 28th, 2009, 07:15 PM
I am interested in the answer to this question. However, I am more interested in how I go about creating a Windows installer that checks and installs the necessary GTK packages as well.

dwhitney67
October 28th, 2009, 07:25 PM
Platform: Windows

When I create an application in C++, which is based on GTK ( UI ), I don't see any difference, but that's just because of the fact that I've installed it's runtime - once I remove it, I can no longer use my app. Now, what should I do to make my application distributable ( so the user could just double-click and use it, without installing any additional packages ) ? What files do I need to include to be able to achieve this ?

You would have to statically link in the GTK libs that your app requires. I am not at all familiar with how windows defines static libraries (note these are not DLLs).

Anyhow, if you statically link in the libraries, expect to find that your application's executable file size to increase substantially.

OpenGuard
October 28th, 2009, 07:39 PM
You would have to statically link in the GTK libs that your app requires. I am not at all familiar with how windows defines static libraries (note these are not DLLs).

Anyhow, if you statically link in the libraries, expect to find that your application's executable file size to increase substantially.


#include <gtk/gtk.h>

int main (int argc, char *argv[])
{
GtkWidget *window;

gtk_init (&argc, &argv);

window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_widget_show (window);

gtk_main ();

return 0;
}As an example ( to not to make it too complicated ), how would I compile this code to get a stand-alone executable ( which can be launched, no matter what runtimes and whatnot the user have previously installed ) ?
** Google said it doesn't know anything about it ( only questions with no real answers ) ..

TheBuzzSaw
October 28th, 2009, 09:17 PM
Wouldn't statically linking in this manner violate the license on GTK?

OpenGuard
October 28th, 2009, 10:36 PM
Wouldn't statically linking in this manner violate the license on GTK?

Would it ?

SledgeHammer_999
October 28th, 2009, 10:43 PM
Why do you use C++ with GTK? If you didn't know, there is gtkmm. Gtkmm is C++ bindings for GTK. link-->www.gtkmm.org

OpenGuard
October 28th, 2009, 10:53 PM
Why do you use C++ with GTK? If you didn't know, there is gtkmm. Gtkmm is C++ bindings for GTK. link-->www.gtkmm.org (http://www.gtkmm.org)

gtkmm is a C++ wrapper for the GTK engine - would that make any difference in terms of portability and ease of use ( from the point of a dumb teenager who doesn't know what GTK means, not to talk about how to install it ) ?

mmix
October 28th, 2009, 10:59 PM
http://gtk-win.sourceforge.net/home/index.php/en/Home

http://dropline.net/past-projects/gtk-runtime-environment-for-windows/

OpenGuard
October 28th, 2009, 11:12 PM
http://gtk-win.sourceforge.net/home/index.php/en/Home

http://dropline.net/past-projects/gtk-runtime-environment-for-windows/

Brilliant! Thank you :)

SledgeHammer_999
October 28th, 2009, 11:19 PM
gtkmm is a C++ wrapper for the GTK engine - would that make any difference in terms of portability and ease of use ( from the point of a dumb teenager who doesn't know what GTK means, not to talk about how to install it ) ?

In terms of portabiility I think it is the same.
In terms of ease of use IMHO I think gtkmm is easier. Everything is handle in C++ terms. Eg a GtkButton is class named Gtk::Button which has all the functions that you use with a GtkButton*. Eg let's say you have Gtk::Button called my_button and a GtkButton* called my_gtk_button. To show the widget in gtkmm you just do a my_button.show(). In Gtk you do something like this gtk_widget_show(GTK_WIDGET(my_gtk_button)) that's ugly and needs more typing. Also with Gtkmm you don't need to play around with pointers(in most cases) and so you don't need to worry that much about unrefing widgets.