简体   繁体   中英

MinGW: winpthreads overrides .rc resource file information

My MinGW project uses the boost library and indirect pthreads.
I created a .rc resource file for my project, containing version information and more.
To static link my executable, I use the parameters:
-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:

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 .
The only hint I get from the linker is:

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

Is the any way I can replace the pthread information by my resource file?

This seems to be a drawback of including all the 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)

But including the whole archive is useful for linking statically the libpthread.a (ie not having the dependency on the DLL).

What I did was to put -Wl,-Bstatic,--whole-archive -lpthread -Wl,--no-whole-archive as the last arguments of the link command:

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

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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