Blog de programación, errores, soluciones

Chose Language:
comments
Author: Admin/Publisher |finished | checked

(gotk3) – error al correr go build(Linux)

Hoy me encuentro probando GTK3 en go para ver si no es mejor que fyne.io y por pura casualidad me encuentro con este error: pkg-config –cflags — gio-2.0 glib-2.0 gobject-2.0 gio-2.0 glib-2.0 gobject-2.0 gio-2.0

project folder
go build
pkg-config --cflags  -- gio-2.0 glib-2.0 gobject-2.0 gio-2.0 glib-2.0 gobject-2.0 gio-2.0
Package gio-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gio-2.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gio-2.0' found
Package glib-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `glib-2.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'glib-2.0' found
Package gobject-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gobject-2.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gobject-2.0' found
Package gio-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gio-2.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gio-2.0' found
Package glib-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `glib-2.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'glib-2.0' found
Package gobject-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gobject-2.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gobject-2.0' found
Package gio-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gio-2.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gio-2.0' found
pkg-config: exit status 1

Para solucionar este error busqué bastante y me encontré con una respuesta de uno de los colaboradores del paquete GTK (mattn) que dice que hay que instalar libgtk+-2.0

Así que procedí a hacer lo que decía mattn. es probable que tengas que correr sudo apt-get update antes de correr el siguiente comando.

apt-get install libgtk2.0-dev libglib2.0-dev libgtksourceview2.0-dev

La página es https://golangrepo.com/repo/mattn-go-gtk-go-gui

Así pues corrí build, esto arreglo algunos de los problemas, pero siguió con algunos otros, a continuación el resultado que tiro correr go build

project folder
go build
pkg-config --cflags -- gdk-3.0 glib-2.0 gobject-2.0 gdk-3.0 glib-2.0 gobject-2.0 gdk-3.0 glib-2.0 gobject-2.0 gdk-3.0 glib-2.0 gobject-2.0 gdk-3.0 glib-2.0 gobject-2.0 gdk-3.0 glib-2.0 gobject-2.0 gdk-3.0 glib-2.0 gobject-2.0 gdk-3.0 glib-2.0 gobject-2.0 gdk-3.0 glib-2.0 gobject-2.0 gdk-3.0 glib-2.0 gobject-2.0 gdk-3.0 glib-2.0 gobject-2.0 gdk-3.0 glib-2.0 gobject-2.0 gmodule-2.0 gdk-3.0 glib-2.0 gobject-2.0
Package gdk-3.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing gdk-3.0.pc' to the PKG_CONFIG_PATH environment variable No package 'gdk-3.0' found Package gdk-3.0 was not found in the pkg-config search path. Perhaps you should add the directory containinggdk-3.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gdk-3.0' found
Package gdk-3.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing gdk-3.0.pc' to the PKG_CONFIG_PATH environment variable No package 'gdk-3.0' found Package gdk-3.0 was not found in the pkg-config search path. Perhaps you should add the directory containinggdk-3.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gdk-3.0' found
Package gdk-3.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing gdk-3.0.pc' to the PKG_CONFIG_PATH environment variable No package 'gdk-3.0' found Package gdk-3.0 was not found in the pkg-config search path. Perhaps you should add the directory containinggdk-3.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gdk-3.0' found
Package gdk-3.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing gdk-3.0.pc' to the PKG_CONFIG_PATH environment variable No package 'gdk-3.0' found Package gdk-3.0 was not found in the pkg-config search path. Perhaps you should add the directory containinggdk-3.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gdk-3.0' found
Package gdk-3.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing gdk-3.0.pc' to the PKG_CONFIG_PATH environment variable No package 'gdk-3.0' found Package gdk-3.0 was not found in the pkg-config search path. Perhaps you should add the directory containinggdk-3.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gdk-3.0' found
Package gdk-3.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing gdk-3.0.pc' to the PKG_CONFIG_PATH environment variable No package 'gdk-3.0' found Package gdk-3.0 was not found in the pkg-config search path. Perhaps you should add the directory containinggdk-3.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gdk-3.0' found
Package gdk-3.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gdk-3.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gdk-3.0' found
pkg-config: exit status 1

Así que seguí buscando como instalar gtk3.0 en linux hasta que encontré la siguiente línea de comandos:

sudo apt-get install build-essential libgtk-3-dev

Esta línea la saque de la siguiente página de preguntas y respuestas. https://askubuntu.com/questions/779065/pkg-config-not-finding-gtk-3-0

es probable que con solo:

 sudo apt-get install build-essential libgtk-3-dev 

Pero es mejor dejar los pasos que se siguieron para que GTK3 funcionara en golang o go como le prefieras llamar. En este momento gtk te debería andar para probar podemos usar el ejemplo que nos dan en gtk3 de go.

main.go
package main

import (
    "github.com/gotk3/gotk3/gtk"
    "log"
)

func main() {
    // Initialize GTK without parsing any command line arguments.
    gtk.Init(nil)

    // Create a new toplevel window, set its title, and connect it to the
    // "destroy" signal to exit the GTK main loop when it is destroyed.
    win, err := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
    if err != nil {
        log.Fatal("Unable to create window:", err)
    }
    win.SetTitle("Simple Example")
    win.Connect("destroy", func() {
        gtk.MainQuit()
    })

    // Create a new label widget to show in the window.
    l, err := gtk.LabelNew("Hello, gotk3!")
    if err != nil {
        log.Fatal("Unable to create label:", err)
    }

    // Add the label to the window.
    win.Add(l)

    // Set the default window size.
    win.SetDefaultSize(800, 600)

    // Recursively show all widgets contained in this window.
    win.ShowAll()

    // Begin executing the GTK main loop.  This blocks until
    // gtk.MainQuit() is run.
    gtk.Main()
}

Probamos en la terminal go build y ./nombre_del_proyecto . El resultado debería ser el siguiente:

Category: go
Something wrong? If you found an error or mistake in the content you can contact me on Twitter | @luisg2249_luis.
Last 4 post in same category

Comments