Create go file for “release”

708 views
Skip to first unread message

ravan...@gmail.com

unread,
Nov 5, 2015, 9:24:39 AM11/5/15
to golang-nuts
hello
I want to make a golang file for "release".
This is my command:
go build -o testi.exe -ldflags "-H windowsgui"
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
    }
}
`


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


this program Compiled for "debug"
Qt5Widgets**d**.dll

Thank you.

James Bardin

unread,
Nov 5, 2015, 9:41:12 AM11/5/15
to golang-nuts, ravan...@gmail.com
You already asked this here:https://forum.golangbridge.org/t/create-go-file-for-release/1415

What question do you have exactly, which the other people who tried to help haven't answered?

ravan...@gmail.com

unread,
Nov 6, 2015, 6:46:54 AM11/6/15
to golang-nuts, ravan...@gmail.com
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.

Konstantin Khomoutov

unread,
Nov 6, 2015, 7:04:45 AM11/6/15
to ravan...@gmail.com, golang-nuts
On Fri, 6 Nov 2015 03:46:32 -0800 (PST)
ravan...@gmail.com wrote:

> 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.

A .dll file is a so-called "dynamically-linked library" which means
to access the functions it exports, the program has to load and link
this library file *at runtime* on the computer it runs.

Hence if the program was deployed on a target computer, and this
library file is not present there, the program won't start.

Since on Windows, the dynamic linker starts to look for a file it was
asked to load and link in the current directory, the easiest way to
ensure your program can run is to ship those DLLs along with your
program (.exe file). That will surely increase the size of the
installation bundle but that's the price to pay for Qt libraries not
being an integral part of the Windows platform.

[...]

ravan...@gmail.com

unread,
Nov 6, 2015, 7:25:34 AM11/6/15
to golang-nuts, ravan...@gmail.com
this means ,runtime should be installed on each system?

Konstantin Khomoutov

unread,
Nov 6, 2015, 7:59:11 AM11/6/15
to ravan...@gmail.com, golang-nuts
On Fri, 6 Nov 2015 04:25:18 -0800 (PST)
ravan...@gmail.com wrote:

> this means ,runtime should be installed on each system?

This means that whatever external (that is, not linked in statically)
libraries a program you want to deploy uses, must be present on the
target system.

There are several ways to achieve this:

* The necessary libraries might already be a part of the target system.

Say, each Windows installation has user32.dll, system32.dll and
all the other DLLs forming Win32 API.

* The necessary libraries might be installed as a separate package.

This is the case for .NET stack on older Windows (pre-Vista),
Java stack, and C/C++ runtime libraries for various versions of
the Visual C++ compiler for Microsoft.

This way, you either require your users to obtain and install
such libraries or ship the installer of them along with your program.

* The necessary libraries might be shipped directly with your
program as I explained in my original reply.

Please read [1] carefully. Then read [2].

1. https://en.wikipedia.org/wiki/Dynamic-link_library
2. http://doc.qt.io/qt-5/windows-deployment.html

Adriano Soares

unread,
Nov 6, 2015, 8:22:39 AM11/6/15
to golang-nuts, ravan...@gmail.com

ravan...@gmail.com

unread,
Nov 7, 2015, 2:28:52 AM11/7/15
to golang-nuts, ravan...@gmail.com
The following command, How was the use?
Libs: -L${libdir} -lQt5Cored

Adriano Soares

unread,
Nov 7, 2015, 6:51:35 AM11/7/15
to golang-nuts, ravan...@gmail.com
It's not a command, it's the line you need to edit.

Open the folder C:\Qt\Qt5.3.2\5.3\mingw482_32\lib\pkgconfig\ (change the numbers to your Qt version).
1. Open a .pc file
2. Find the line beginning with Libs:
3. Remove the last d on the line
4. Repeat for all .pc files

ravan...@gmail.com

unread,
Nov 7, 2015, 12:35:14 PM11/7/15
to golang-nuts, ravan...@gmail.com
(change the numbers to your Qt version).
version  my Qt = 5.5 , What do I change?
I convert :
Libs: -L${libdir} -lQt5Widgetsd  to Libs: -L${libdir} -lQt5Widgets
Libs: -L${libdir} -lQt5Quickd  to Libs: -L${libdir} -lQt5Quick
Libs: -L${libdir} -lQt5Qmld  to Libs: -L${libdir} -lQt5Qml
Libs: -L${libdir} -lQt5Networkd to Libs: -L${libdir} -lQt5Network
Libs: -L${libdir} -lQt5Guid to Libs: -L${libdir} -lQt5Gui
But The problem is not solved.

ravan...@gmail.com

unread,
Nov 17, 2015, 1:08:06 AM11/17/15
to golang-nuts, ravan...@gmail.com
 I didn't find my answer. has any one a training film?
for windows.
Thank you.

ravan...@gmail.com

unread,
Nov 19, 2015, 3:57:21 AM11/19/15
to golang-nuts, ravan...@gmail.com



I have created release file.
But go file isn't execute out of workspace dir.

my list dll :

my code: for Qt5Core.pc
prefix=F:\\qt\\5.5\\mingw492_32
exec_prefix
=${prefix}
libdir
=${prefix}/lib
includedir
=${prefix}/include

host_bins
=${prefix}/bin
qt_config
=minimal-config small-config medium-config large-config full-config debug_and_release build_all debug release c++11 shared zlib dynamicgl png freetype harfbuzz build_all accessibility opengl ssl openssl dbus audio-backend native-gestures qpa iconv concurrent

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}


On Thursday, November 5, 2015 at 5:54:39 PM UTC+3:30, ravan...@gmail.com wrote:

Konstantin Khomoutov

unread,
Nov 19, 2015, 6:49:19 AM11/19/15
to ravan...@gmail.com, golang-nuts
On Thu, 19 Nov 2015 00:56:57 -0800 (PST)
ravan...@gmail.com wrote:

> I have created release file.
> But go file isn't execute out of workspace dir.
>
> <https://lh3.googleusercontent.com/-xRTzCdmEI_4/Vk2NRFH_5OI/AAAAAAAAAEI/HsQzybVDU2E/s1600/golang.gif>

What happens if you run that program from a console window?
Does it print anything?

ravan...@gmail.com

unread,
Nov 19, 2015, 7:34:09 AM11/19/15
to golang-nuts, ravan...@gmail.com
it doesn't show any things.
But it shows in this dir: F:\workspace

On Thursday, November 5, 2015 at 5:54:39 PM UTC+3:30, ravan...@gmail.com wrote:

ravan...@gmail.com

unread,
Nov 19, 2015, 12:54:58 PM11/19/15
to golang-nuts, ravan...@gmail.com
in the cmd , After the command under:
F:\>cd workspace
F:\workspace>go run test.go
the winow is showing.

After the command under::
F:\workspace>go build test.go
the file is built.
But in another folder does not work . 

On Thursday, November 5, 2015 at 5:54:39 PM UTC+3:30, ravan...@gmail.com wrote:

Konstantin Khomoutov

unread,
Nov 19, 2015, 1:40:49 PM11/19/15
to ravan...@gmail.com, golang-nuts
On Thu, 19 Nov 2015 09:54:41 -0800 (PST)
ravan...@gmail.com wrote:

> in the cmd , After the command under:
> F:\>cd workspace
> F:\workspace>go run test.go
> the winow is showing.
>
> After the command under::
> F:\workspace>go build test.go
> the file is built.
> But in another folder does not work .

Grab the Sysinternals suite [1] and figure out how to use the "procmon"
program available in it: it's able to capture all "external" activity
of a program regarding it accessing filesystem, registry and network.

Run your compiled executable in "another folder" while monitoring it in
procmon and figure out what file it fails to load.

(Just to make sure: when I say "figure out" I really mean you studying
it and trying to make sense out of its data, not you grabbing the
procmon's log and dumping it here.)

1. https://technet.microsoft.com/en-us/sysinternals/bb842062

ravan...@gmail.com

unread,
Nov 20, 2015, 1:19:52 PM11/20/15
to golang-nuts, ravan...@gmail.com
my problem because doesn't have qml file Which was resolved.
But It has a problem in another computer now.
should I install visual c++?


On Thursday, November 5, 2015 at 5:54:39 PM UTC+3:30, ravan...@gmail.com wrote:

Konstantin Khomoutov

unread,
Nov 20, 2015, 1:51:35 PM11/20/15
to ravan...@gmail.com, golang-nuts
On Fri, 20 Nov 2015 10:19:35 -0800 (PST)
ravan...@gmail.com wrote:

> my problem because doesn't have qml file Which was resolved.
> *But It has a problem in another computer now.*
> *should I install visual c++?*

Consider applying the same approach you've used to solve your current
project -- but this time on that another computer.

Please understand that asking vague questions is of little help because
the answer to your question -- as stated -- is "maybe".
Grab depends.exe, look at your executable on that another machine --
is the tool able to find all the relevant DLLs?
Grab procmon.exe, run your executable, see what libraries/files it tries
to load, and fails.

Please just try that. Solving problems is about coming up with
solutions and *trying* them.

ravan...@gmail.com

unread,
Nov 21, 2015, 2:55:33 AM11/21/15
to golang-nuts, ravan...@gmail.com
There is no need to "procmon.exe"
If the dll file is not , program gives the following warning:

The program can't start because Qt5Core.dll is missing from your computer.
Try reinstalling the program to fix this problem.


On Thursday, November 5, 2015 at 5:54:39 PM UTC+3:30, ravan...@gmail.com wrote:

ravan...@gmail.com

unread,
Nov 24, 2015, 3:13:54 AM11/24/15
to golang-nuts, ravan...@gmail.com
The problem was solved:
start Procmon.exe

C:\ravandi\user>d:
D:\>cd D:\go\sahih
D:\go\sahih>start test.exe

Files and folders required:
dir platforms
dir QtQuick
dir QtQuick.2
libgcc_s_dw2-1.dll
libstdc++-6.dll
libwinpthread-1.dll
main.qml
Qt5Core.dll
Qt5Gui.dll
Qt5Network.dll
Qt5Qml.dll
Qt5Quick.dll
Qt5Widgets.dll
test.exe
Thank you. 



On Thursday, November 5, 2015 at 5:54:39 PM UTC+3:30, ravan...@gmail.com wrote:

Konstantin Khomoutov

unread,
Nov 24, 2015, 5:49:28 AM11/24/15
to ravan...@gmail.com, golang-nuts
On Tue, 24 Nov 2015 00:12:29 -0800 (PST)
ravan...@gmail.com wrote:

> The problem was solved:
> start Procmon.exe
>
> C:\ravandi\user>d:
> D:\>cd D:\go\sahih
> D:\go\sahih>start test.exe
>
> Files and folders required:
[...]
> Qt5Core.dll
[...]

Glad you got it sorted.

I think it's the time for you to revisit this whole thread [1] and the
documentation it points at, especially [2] and [3].

1. https://groups.google.com/d/topic/golang-nuts/xF-5q-8PNhY/discussion
2. https://en.wikipedia.org/wiki/Dynamic-link_library
3. http://doc.qt.io/qt-5/windows-deployment.html
Reply all
Reply to author
Forward
0 new messages