简体   繁体   English

MinGW:winpthreads overrides.rc 资源文件信息

[英]MinGW: winpthreads overrides .rc resource file information

My MinGW project uses the boost library and indirect pthreads.我的 MinGW 项目使用 boost 库和间接 pthreads。
I created a .rc resource file for my project, containing version information and more.我为我的项目创建了一个.rc资源文件,其中包含版本信息等。
To static link my executable, I use the parameters:到 static 链接我的可执行文件,我使用参数:
-static-libgcc -static-libstdc++ -Wl,-Bstatic,--whole-archive -lpthread -Wl,--no-whole-archive

Sadly, pthread overwrites my resource information and windows-explorer shows now this for my .exe executable:可悲的是,pthread 覆盖了我的资源信息,windows-explorer 现在为我的.exe可执行文件显示了这个:

description:   POSIX WinThreads for Windows
original name: WinPthreadGC
[...]

Without the linking options for pthread, the information windows-explorer gives me is the same like in my resource file, but my executable depends on the libwinpthread-1.dll .如果没有 pthread 的链接选项,windows-explorer 给我的信息与我的资源文件中的信息相同,但我的可执行文件取决于libwinpthread-1.dll
The only hint I get from the linker is:我从 linker 得到的唯一提示是:

.../bin/ld.exe: .rsrc merge failure: duplicate leaf: type: 10 (VERSION) name: 1 lang: 409

Which seems reasonable, since VERSION and lang is different in my resource file and I want to get rid of this stuff from pthread.这似乎是合理的,因为VERSIONlang在我的资源文件中是不同的,我想从 pthread 中删除这些东西。

Is the any way I can replace the pthread information by my resource file?有什么方法可以用我的资源文件替换 pthread 信息吗?

This seems to be a drawback of including all the archive ( --whole-archive ):这似乎是包含所有存档( --whole-archive )的一个缺点:
-Wl,-Bstatic,--whole-archive -lpthread -Wl,--no-whole-archive

(in the libpthread.a , there is a version.o containing a compiled VERSIONINFO resource) (在libpthread.a中,有一个version.o包含已编译的VERSIONINFO资源)

But including the whole archive is useful for linking statically the libpthread.a (ie not having the dependency on the DLL).但是包括整个存档对于静态链接libpthread.a很有用(即不依赖于 DLL)。

What I did was to put -Wl,-Bstatic,--whole-archive -lpthread -Wl,--no-whole-archive as the last arguments of the link command:我所做的是将-Wl,-Bstatic,--whole-archive -lpthread -Wl,--no-whole-archive作为链接命令的最后一个 arguments :

gcc <files> -Wl,--whole-archive -lpthread -Wl,--no-whole-archive

instead of:代替:

gcc -Wl,--whole-archive -lpthread -Wl,--no-whole-archive <files>

(with your compiled resource file in the <files> ) (在<files>中使用您编译的资源文件)

Then I still have the message .rsrc merge failure: duplicate leaf , but the link performs properly and the executable has the correct version info, ie the first one provided at the command line.然后我仍然有消息.rsrc merge failure: duplicate leaf ,但链接执行正常并且可执行文件具有正确的版本信息,即命令行提供的第一个信息。

Another option would be to create another library by copying libpthread.a , and remove version.o from the archive ( ar -d libmypthread.a version.o ), and link with this archive.另一种选择是通过复制libpthread.a创建另一个库,并从存档中删除version.o ( ar -d libmypthread.a version.o ),并与此存档链接。

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

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