Home > other >  Link in resources
Link in resources

Time:01-21

Looks like there are tons of webpages online and questions on SO, but I still can't get this to work after several hours of searching.

I'm cross-compiling from Linux to Windows by setting CC/CXX to x86-64 MinGW-w64. Compilation actually works and the exe runs fine on Windows.

With file I get this output:

PE32  executable (GUI) x86-64 (stripped to external PDB), for MS Windows

I have two resource files (a Windows *.ico file and a *.res ASCII file that contains properties such as VERSIONINFO and the like).

The two resource files are transformed into *.o files with MinGW's windres tool. They look like COFF files now. That's as far as I could get.

What I want to do is link those two resources into the exe.

I don't find any way to instruct the Go linker to include those files during linking (I run go build, not go tool). I've also tried to add the resource post-linking with objcopy following various pages online and other SO questions... but to no avail.

All I want is Windows to recognize those two resources (icon and info) so that the executable behaves like any other on Windows.

If I should instruct the Go linker (go tool instead of go build), then how can I tell it which files to link? I have "simple" *.go files and then C dependencies (GLFW and OpenGL) I link with CGO.

How can this be done on the Linux command-line? I want to add these steps to a broader CI/CD (build workflow/asset pipeline). A Windows GUI tool or similar would not help much.

Thanks!

CodePudding user response:

I don’t know if you are using Fyne, but it sounds like what “fyne package” does (embed icon and metadata).

If you are in Fyne land then you can use their tools, if not maybe check out the source and see for yourself how it’s done? https://github.com/fyne-io/fyne/blob/master/cmd/fyne/internal/commands/package-windows.go

  • Related