-4

I want to make a Golang File For "Release".

This is my command:

go build -o testi.exe -ldflags "-H windowsgui"

What is the correct way? My code:

package main
import (
    "fmt"
    "os"
    //"github.com/chai2010/qml"
    "github.com/go-qml/qml"
)
func main() {
    if err := qml.Run(run); err != nil {
        fmt.Fprintf(os.Stderr, "error: %v\n", err)
        os.Exit(1)
    }
}
func run() error {
    engine := qml.NewEngine()
    engine.On("quit", func() { os.Exit(0) })

    component, err := engine.LoadString("hello.qml", qmlHello)
    if err != nil {
        return err
    }
    window := component.CreateWindow(nil)
    window.Show()
    window.Wait()
    return nil
}

const qmlHello = `
import QtQuick 2.2
import QtQuick.Controls 1.1
Rectangle {
    id: page
    width: 320; height: 240
    color: "lightgray"
    Text {
        id: helloText
        text: "Hello world!"
        y: 30
        anchors.horizontalCenter: page.horizontalCenter
        font.pointSize: 24; font.bold: true
    }
}
`

I installed : go1.5.windows-386.

peterh
  • 11,875
  • 18
  • 85
  • 108
ravandi
  • 49
  • 5
  • what do you mean by 'For "Release"'? – JimB Nov 02 '15 at 18:22
  • In C ++ is two modes:Release And Debug.example: in qt and c++ the program is 25.0 KB for "release" And for debug : 850 KB . – ravandi Nov 02 '15 at 18:27
  • It might mean something in your IDE, but that's not a C++ thing. I'm not sure what you expect Go to build differently for Release, if you don't have anything specifically configured for not-Release. – JimB Nov 02 '15 at 18:30
  • size total program with dll : 743mb Everything that needs: libgcc_s_dw2-1.dll libstdc++-6.dll libwinpthread-1.dll Qt5Cored.dll Qt5Guid.dll Qt5Networkd.dll Qt5Qmld.dll Qt5Quickd.dll Qt5Widgetsd.dll – ravandi Nov 02 '15 at 18:38
  • 2
    See other discussion on this question at https://forum.golangbridge.org/t/create-go-file-for-release/1415 – Charlie Tumahai Nov 02 '15 at 18:55
  • How big is your binary? Go doesn't build any of those other artifacts, and it's up to you to provide them in some way. – JimB Nov 02 '15 at 18:58
  • I Ran exe file. It Warned: The program can't start because Qt5Cored.dll is missing from your computer. Try reinstalling the program to fix this problem. This program Compiled for "debug" – ravandi Nov 03 '15 at 06:42
  • Possible duplicate of [How to build a release version binary in Go?](https://stackoverflow.com/questions/29599209/how-to-build-a-release-version-binary-in-go) – gonutz Sep 14 '17 at 12:22

1 Answers1

0

As explained by JimB, Dave Cheney, and others:

  • There is no "RELEASE" for Golang
  • Golang executables are large, that is normal
  • Yes, you have to provide to DLL files if you force linking shared libraries
  • Yes, those libraries might be large.
  • There is nothing wrong, just let go use the defaults
user918176
  • 1,770
  • 13
  • 34
  • I have created release file. But It has a problem in another computer now. The go file , isn't execute in another computer now. – ravandi Nov 22 '15 at 04:24
  • The problem was solved. I used the following programs: procmon.exe – ravandi Nov 24 '15 at 10:16