1

Basically, I wrote a program using Go and the binding for the Qt gui library (github.com/bluszcz/cutego). I moved over to the cutego fork because the original binding (github.com/therecipe/qt) isn't being maintained anymore.

My app works great but I need it to run on a machine that needs nothing installed. I'm new to Go so please forgive my ignorance. I followed the instructions to build a static executable here: (https://github.com/therecipe/qt/wiki/Deploying-Windows-to-Windows-64-bit-Static)

I get a few deprecated code warnings but the code does compile. The problem is I still end up with a dynamically compiled executable. I ran ldd using MINGW64 and I get:

Qt5Core.dll => not found Qt5Gui.dll => not found Qt5Widgets.dll => not found

As mentioned I am pretty new to Go, but I am also new to this kind of language as I have only developed using Python and VBA. I haven't found any clues online, I think because there's something really obvious that I am missing that everyone else knows about already.

What am I missing here? Any help would be most appreciated!

I would like my executable to be statically typed so that it can run without Qt installed.

Dilemma
  • 31
  • 4
  • To clarify I also get the following error when I try go build: C:\Program Files\Go\pkg\tool\windows_amd64\link.exe: running g++ failed: exit status 1 C:/Users/Public/env_windows_amd64_Tools/mingw730_64/bin/../lib/gcc/x86_64-w64-mingw32/7.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lzstd C:/Users/Public/env_windows_amd64_Tools/mingw730_64/bin/../lib/gcc/x86_64-w64-mingw32/7.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lzstd collect2.exe: error: ld returned 1 exit status – Dilemma Feb 05 '23 at 20:39

2 Answers2

0

When you use cgo, your go executable will link to shared libraries at run time depending on what C libraries the cgo code references.

If you wish to use cgo and have a stand alone executable you need to link your binary to static libraries (typically .a files). It is up to the third party module to provide such libraries, though, and qt may not provide them out of the box.

jdizzle
  • 4,078
  • 1
  • 30
  • 38
  • thank you! That's a huge hint. So, I found those .a files - I think. The names line up with the (3) dlls mentioned above. I tried searching for how to link up to the directory with the .a files and found this: [link](https://www.arp242.net/static-go.html). I'm still very unclear how to do what you mentioned to at least test the theory that I found the right files. Any suggestions on where to look? – Dilemma Feb 06 '23 at 02:34
  • Try the techniques in [this post](https://stackoverflow.com/questions/725472/static-link-of-shared-library-function-in-gcc#725550). You’ll need to use the CCFLAGS environment variable I think. – jdizzle Feb 06 '23 at 12:00
0

I found the problem. So with github.com/therecipe/qt you have 2 install options. You can either install the normal default way or you can install using the "static" method. You'll have problems if you do both. I ended up removing all files relative to github.com/therecipe/qt. I then installed using the static Windows x64 to Windows x64 method ONLY and followed those instructions for deploying a static executable. Worked like a charm using the instructions for MYSYS2.

Dilemma
  • 31
  • 4