hello
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?
hello
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?
Yes. The go compiler always compiles in “release” mode.
I’m sorry if I did not understand your question.
I tried the commands:
go build -ldflags “-s” testi.go
size:2.06 MB
go build testi.go
size:4.96 MB
go build -o testi.exe -ldflags "-H windowsgui"
size:4.96 MB
First Command Is Lesser Size. but opens cmd.
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
}
}
`
-s is not recommended as it produces broken binaries. In some versions of Go, -s has no effect.
I installed : go1.5.windows-386.
This command works:
go build -ldflags “-s” testi.go
This amount is not high? “size:4.96 MB”
I don’t think so, 4.96mb for a whole program, including qml seems reasonable.
https://golang.org/doc/faq#Why_is_my_trivial_program_such_a_large_binary
See also
in qt and c++
the program is 25.0 KB for “release” And for debug : 850 KB .
but in go:4.96 MB
Go is not C, or C++. Go programs are generally statically linked and are generally larger than programs which are dynamically linked.
See https://golang.org/doc/faq#Why_is_my_trivial_program_such_a_large_binary
4.96 mb is the correct size for your program.
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
my command:
go build -o testi.exe -ldflags “-H windowsgui”
this program Compiled for "debug"
Qt5Widgetsd.dll
This is as good as it gets. Please review the links I pasted above.
Means:runtime program on any system should be installed?
The runtime package is always linked into each Go program. This accounts for some (not all) of the size of a Go program.
I can not understand what your mean.
What he means is that the way the binaries produced by the Go compiler are structured, they include all the runtime bits and pieces it needs. This is what makes the binaries look large in comparison to other languages.
As for the debug vs non-debug part of your question, I don’t know my way around windows to give you an answer, but perhaps I can nudge you in the right direction. QML uses MinGW to build. In https://github.com/go-qml/qml/blob/v1/bridge.go it specifies the Qt libraries it pkg-config to find. If you look at the .pc file for Qt, it’s hard-coded to use the debug libraries. If you edit that file (Qt5Core.pc Qt5Widgets.pc Qt5Quick.pc), you can remove the “d” from the library names.
My Problem Is with “release”
If you mean here:
F:\qt\5.5\mingw492_32\lib\pkgconfig
there are not these files at all:
Qt5Cored.pc Qt5Widgetsd.pc Qt5Quickd.pc
Hello,
I’m sorry you haven’t been able to get the answers you need. It would be valuable if you could take some time to explain the background of the issue you are having. Possibly this form would be useful
I’m trying to describe your desired goal
So far I have tried describe the steps you have tried to achieve this goal
I expected it to do describe what you expected to happen
But instead describe what happened when you tried the steps you outlined above
So far you have mentioned
If these are all questions you have, I recommend starting a new thread for each of them.
Thanks
Dave
Why does it give me this error message?
The program can’t start because Qt5Cored.dll is missing from your computer.
Try reinstalling the program to fix this problem.
I have created release file.
But go file isn’t execute out of workspace dir:
my list dll :
my code: for Qt5Core.pc
Name: Qt5 Core
Description: Qt Core module
Version: 5.5.0
Libs: -L${libdir} -lQt5Core
Libs.private: -lole32 -luuid -lws2_32 -ladvapi32 -lshell32 -luser32 -lkernel32 -lmpr .obj\debug\Qt5Cored_resource_res.o -LF:\\qt\\5.5\\mingw492_32/lib -lqtpcred
Cflags: -I${includedir}/QtCore -I${includedir}