简体   繁体   English

资源链接

[英]Link in resources

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.看起来网上有很多网页和关于 SO 的问题,但经过几个小时的搜索我仍然无法让它工作。

I'm cross-compiling from Linux to Windows by setting CC/CXX to x86-64 MinGW-w64.我通过将 CC/CXX 设置为 x86-64 MinGW-w64,从 Linux 交叉编译到 Windows。 Compilation actually works and the exe runs fine on Windows.编译确实有效,exe 在 Windows 上运行良好。

With file I get this output:有了file ,我得到了这个 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).我有两个资源文件(一个 Windows *.ico文件和一个包含VERSIONINFO等属性的*.res ASCII 文件)。

The two resource files are transformed into *.o files with MinGW's windres tool.这两个资源文件用MinGW的windres工具转化为*.o文件。 They look like COFF files now.它们现在看起来像 COFF 文件。 That's as far as I could get.这是我所能得到的。

What I want to do is link those two resources into the exe.我想要做的是将这两个资源链接到 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 ).我找不到任何方法来指示 Go linker 在链接期间包含这些文件(我运行go build ,而不是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.我还尝试在各种在线页面和其他 SO 问题之后添加objcopy的资源后链接......但无济于事。

All I want is Windows to recognize those two resources (icon and info) so that the executable behaves like any other on Windows.我想要的只是 Windows 来识别这两个资源(图标和信息),以便可执行文件的行为与 Windows 上的任何其他资源一样。

If I should instruct the Go linker ( go tool instead of go build ), then how can I tell it which files to link?如果我应该指示 Go linker( go tool而不是go build ),那么我如何告诉它链接哪些文件? I have "simple" *.go files and then C dependencies (GLFW and OpenGL) I link with CGO.我有“简单的” *.go文件,然后是 C 依赖项(GLFW 和 OpenGL)我与 CGO 链接。

How can this be done on the Linux command-line?如何在 Linux 命令行上完成此操作? I want to add these steps to a broader CI/CD (build workflow/asset pipeline).我想将这些步骤添加到更广泛的 CI/CD(构建工作流程/资产管道)。 A Windows GUI tool or similar would not help much. Windows GUI 工具或类似工具帮不上什么忙。

Thanks!谢谢!

I don't know if you are using Fyne, but it sounds like what “fyne package” does (embed icon and metadata).我不知道您是否在使用 Fyne,但这听起来像是“fyne 包”的作用(嵌入图标和元数据)。

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?如果您在 Fyne land,那么您可以使用他们的工具,如果不是,也许可以查看源代码并亲自看看它是如何完成的? https://github.com/fyne-io/fyne/blob/master/cmd/fyne/internal/commands/package-windows.go https://github.com/fyne-io/fyne/blob/master/cmd/fyne/internal/commands/package-windows.go

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM