How to configure gtk to upgrade to Win 7

I would like to create a small graphical interface with access to windows 7 32bit. This is what I did:

To verify the installation, I typed gcc at the command prompt. It returned a realgcc error : no input file , so it seems that gcc is installed correctly. Then I tried to run gtk-demo . It worked too

  • My installation is tested and working fine. I have already developed a small server with it. GOROOT and GOPATH are installed correctly.
  • To install go-gtk, I used go get github.com/mattn/go-gtk/gtk

Installation completed with many warnings.

C: \ Users \ lhk> go get github.com/mattn/go-gtk/gtk

# github.com/mattn/go-gtk/glib

realgcc.exe: warning: '-xc' after the last input file has no effect

realgcc.exe: no input files

# github.com/mattn/go-gtk/gdk

realgcc.exe: warning: '-xc' after the last input file has no effect

realgcc.exe: no input files

# github.com/mattn/go-gtk/pango

realgcc.exe: warning: '-xc' after the last input file has no effect

realgcc.exe: no input files

C: \ Users \ LHK>

To test the go-gtk installation, I used a sample code here: http://mattn.imtqy.com/go-gtk/ . I tried to run this code with go run , but it completed the error message:

# github.com/mattn/go-gtk/glib
realgcc.exe: warning: '-xc' after the last input file does not affect realgcc.exe: no input files
# github.com/mattn/go-gtk/gdk
realgcc.exe: warning: '-xc' after the last input file does not affect realgcc.exe: no input files
# github.com/mattn/go-gtk/pango
realgcc.exe: warning: '-xc' after the last input file does not affect realgcc.exe: no input files
exit status 2

What I did wrong? How to configure gtk to use with go correctly?

Update

mb0 on the Go IRC channel really helped and pointed out this https://groups.google.com/forum/?fromgroups#!topic/golang-nuts/GwbkQREiTZI

The go-gtk creator apparently got go-gtk to work on win32. He did not use. Instead, he cloned the github repository into the src folder on his GOPATH and used the mingw compiler shell to call mingw32-make.

I did the same: cloned the repo and named mingw32-make. It starts compiling, but does not appear with an error message:

# pkg-config --cflags gtksourceview-2.0

The gtksourceview-2.0 package was not found in the pkg-config search path.

Perhaps you should add a directory containing "gtksourceview-2.0.pc"

for the PKG_CONFIG_PATH environment variable

No package "gtksourceview-2.0" found exit status

1 mingw32-make: * [all] Error 2

This gives some specific recommendations. Obviously, there is a package configuration utility, and it does not find an important package. Unfortunately, I do not understand how to solve this. I checked the gtk site and found this article in pkg-config http://www.gtk.org/api/2.6/gtk/gtk-compiling.html

It seems to me that pkg-config is responsible for setting up import packages. Therefore, I hesitate to simply create the variable PKG_CONFIG_PATH, since I do not know where it should indicate. I just tried running shell commands in my mingw shell: pkg-config --cflags gtk+-2.0 and pkg-config --libs gtk+-2.0 . The first, apparently, displays a list of included paths, and the second just prints the available libraries. There are pango, cairo, gobject, pixbuf, and many others, but there is definitely no library called something like gtksourceview.

I assume that I do not have this library on my machine. This bothers me, as I downloaded and unpacked everything in one bundle, which was supposed to satisfy all the dependencies.

What can I do to solve this problem?

+4
source share
2 answers

Finally it works. Here is a step-by-step guide on how to get gtk to work with Windows 32bit with go.

  • Install Mingw and Msys
  • Download the gtk all-in-one package here http://www.gtk.org/download/win32.php
  • Unzip it to C: \ GTK. I heard that the name is important. Personally, I cannot think of a reason why, but you can keep this in mind as a possible source of errors.
  • Add the bin folder to your path. Now you can run gtk-demo from your shell.

The gtk website reports that the all-in-one package contains both gtk + stack and third-party dependencies. But in order to compile go-gtk on windows, you will need to install additional libraries.

You need gtksourceview and libxml. They can be found here: http://ftp.gnome.org/pub/gnome/binaries/win32/gtksourceview/2.10/ and here: http://ftp.gnome.org/pub/GNOME/binaries/win32/dependencies/

The download will be an encrypted file containing various folders. You need to unzip the folders and copy them to C: \ GTK. Windows will ask you if you want to integrate them into existing ones. Yes Yes. Now you have downloaded all the dependencies.

  • Open the Mingw shell and go to the go-gtk folder
  • Call "pkg-config --cflags gtk + -2.0"
  • Call "pkg-config --libs gtk + -2.0"
  • Call mingw32-make

Compilation should work fine. If there are errors, and mingw complains about the missing libraries, you should install them the same way you installed gtksourceview and libxml.

Now to check go-gtk

  • Create a new folder in the go src directory. I called it "gtktest"
  • Create a new .go file.
  • Copy the sample code: http://mattn.imtqy.com/go-gtk/
  • use go build to create exe

Hope this helps you use go and gtk for windows.

+3
source

I am trying to run the GUI infrastructure in GO / Windows, and I finally was able to do this according to your instructions.

I have only a few additions:

  • I added "C: \ GTK \ bin" to PATH instead of "C: \ GTK"
  • I had to add a third dependency: pthreads
  • To load the correct dependency: take each time a file containing "dev" in its file name
  • The mingw console can be found at C: \ MinGW \ msys \ 1.0 \ msys.bat
0
source

Source: https://habr.com/ru/post/1485171/


All Articles