Ákos Vandra-Meyer
Ákos Vandra-Meyer

Reputation: 2175

Getting GTK# app to run on windows

I am unable to get a GTK# app to run on windows, and I would appreciate any help I can get. I tried googleing around, but was unable to find a solution for my problem.

I wrote a small app in monodevelop using GTK#, which just opens a window with a button. It runs fine on linux.

However I am unable to get it to run on windows. I tried installing the GTK+ and the GTK# redistributables, the GTK# SDK, but it still does not work. And it does not show any exceptions thrown (in the command line), which would be helpful for debugging the problem.

After invoking the .exe, it sits there for a few seconds, and after that the shell reappears waiting for the next command, no output whatsoever.

Can anyone please walk me through what do I have to install on a virgin windows install to be able to run GTK# applications?

[edit] I understand mono is not needed to run them, and would like to avoid it, if possible.

Upvotes: 1

Views: 2825

Answers (4)

LFMekz
LFMekz

Reputation: 723

Much like you I had an issue running on Windows 10. The issue in my case was resolved after another Google Result to a blog which mentions that the Mono.Posix references are indeed the cause. However, the blog indicated that you must also delete/convert global::Mono.Unix.Catalog.GetString (if you are using MonoDevelop's Stetic GUI creator). Those will be usually on your Labels.

ie:

dev@laptop:/tmp/myproject$ rg "global::Mono.Unix."
96:     this.label2.LabelProp = global::Mono.Unix.Catalog.GetString("25 ROUNDS OF DEAF");

changes to

96:     this.label2.LabelProp = "25 ROUNDS OF DEAF"

Since Stetic GUI creator usually puts Partial class files in the subfolder gtk-gui of the project directory. That's probably the best place to check for strays. Although ripgrep (the rg command used up there does recursive fast directory searching of all child folders so might as well use that)

After this you must install the GTKSharp Runtime for .NET (as of today it's file gtk-sharp-2.12.45.msi from mono-project.com for GTK+ also known as GTK2. GTK3 is different and it may be different for future Googler's)

After that recompile the application in MonoDevelop and you can run it on Windows

Source of steps: https://www.martyndavis.com/?p=432

Upvotes: 1

Jeff
Jeff

Reputation: 159

Mono.Posix is a required part of the GTK# system - it contains the gettext library interface used to handle internationalized text. By writing in MonoDevelop, there is an option to allow internationalized text when creating the GUI interfaces, which will automatically call this library as part of the generated Build function (it seems to be called when setting user-displayed text, like the title of your form). This means you only need the Mono.Posix.dll library (which will work on Microsoft .NET), not the full Mono runtime.

Upvotes: 2

ViKozh
ViKozh

Reputation: 56

Actually application can run without Mono (console apps, for example) on Windows, but if you have reference to Mono.Posix in code, it can use some platform-specific functions that couldn't be executed on Windows. On Windows in MonoDevelop you can choose between frameworks (Mono or MS.Net). Try to recompile app on Win with MS.Net framework selected.

Upvotes: 0

jpobst
jpobst

Reputation: 9982

The exception may be getting written to stderr instead of stdout, which the Windows command line does not show by default. Try:

myapp.exe 2> my.log

and see if that writes the error to a logfile called my.log.

Upvotes: 1

Related Questions