Windows build on mingw 5.3 ld.exe ".rsrc merge failure"

• Mar 16, 2017 - 11:17

Jojo and I have been trying to figure out this linker error. Musescore still runs fine, but since it is an error, QtCreator will throw up a popup and so won't execute mscore when press F5.

[ 57%] Linking CXX executable MuseScore.exe
C:/Qt/Tools/mingw530_32/bin/../lib/gcc/i686-w64-mingw32/5.3.0/../../../../i686-w64-mingw32/bin/ld.exe: .rsrc merge failure: duplicate leaf: type: e (GROUP_ICON) name: IDI_ICON2 lang: 409
C:/Qt/Tools/mingw530_32/bin/../lib/gcc/i686-w64-mingw32/5.3.0/../../../../i686-w64-mingw32/bin/ld.exe: .rsrc merge failure: duplicate leaf: type: e (GROUP_ICON) name: IDI_ICON1 lang: 409
C:/Qt/Tools/mingw530_32/bin/../lib/gcc/i686-w64-mingw32/5.3.0/../../../../i686-w64-mingw32/bin/ld.exe: .rsrc merge failure: duplicate leaf: type: 3 (ICON) name: 8 lang: 409
C:/Qt/Tools/mingw530_32/bin/../lib/gcc/i686-w64-mingw32/5.3.0/../../../../i686-w64-mingw32/bin/ld.exe: .rsrc merge failure: duplicate leaf: type: 3 (ICON) name: 7 lang: 409
C:/Qt/Tools/mingw530_32/bin/../lib/gcc/i686-w64-mingw32/5.3.0/../../../../i686-w64-mingw32/bin/ld.exe: .rsrc merge failure: duplicate leaf: type: 3 (ICON) name: 6 lang: 409
C:/Qt/Tools/mingw530_32/bin/../lib/gcc/i686-w64-mingw32/5.3.0/../../../../i686-w64-mingw32/bin/ld.exe: .rsrc merge failure: duplicate leaf: type: 3 (ICON) name: 5 lang: 409
C:/Qt/Tools/mingw530_32/bin/../lib/gcc/i686-w64-mingw32/5.3.0/../../../../i686-w64-mingw32/bin/ld.exe: .rsrc merge failure: duplicate leaf: type: 3 (ICON) name: 4 lang: 409
C:/Qt/Tools/mingw530_32/bin/../lib/gcc/i686-w64-mingw32/5.3.0/../../../../i686-w64-mingw32/bin/ld.exe: .rsrc merge failure: duplicate leaf: type: 3 (ICON) name: 3 lang: 409
C:/Qt/Tools/mingw530_32/bin/../lib/gcc/i686-w64-mingw32/5.3.0/../../../../i686-w64-mingw32/bin/ld.exe: .rsrc merge failure: duplicate leaf: type: 3 (ICON) name: 2 lang: 409
C:/Qt/Tools/mingw530_32/bin/../lib/gcc/i686-w64-mingw32/5.3.0/../../../../i686-w64-mingw32/bin/ld.exe: .rsrc merge failure: duplicate leaf: type: 3 (ICON) name: 1 lang: 409


Comments

upon tracing where IDI_ICON1 was used, I stumbled onto this:

1. It is only mentioned in one place in the sources: /mscore/data/mscore.rc (github)
This file hasn't been changed in the past 5 years.
--> So something in the buildprocess makes it so that this resource within this file is included twice when linking MuseScore.exe

2. It is only built by one command: /mscore/CMakeLists.txt#L420 and following.
--> resulting file: resfile.o

3. That file is added to the LINK_FLAGS for the mscore target (L440 of the link above).
Also found it mentioned in/used by /build.qtc/mscore/CMakeFiles/mscore.dir/link.txt

[EDIT] the seemingly only other occurence of this linker error happened in the xHarbour project. It is fairly unclear how exactly they fixed it, but as far as I can tell, they have added -DWIN32 to the compiler flags if building on a 64-bit architecture.
Both on your as mine system the linker called from mingw530_32/bin/ is mingw530_32\i686-w64-mingw32\bin\ld.exe which hints at it being 64bit indeed. Perhaps we'll need an explicit define for WIN32 as well?

In reply to by jeetee

Good findings! Have you tried with -DWIN32?

Edit: I've just tried and it seem -DWIN32 cand PCH are mutually exclusive:

cc1plus.exe: warning: .../MuseScore/build.qtc/all.h.gch: not used because `WIN32' is defined [-Winvalid-pch]

And it doesn't cure the issue at hand here, pity...

In reply to by jeetee

No dice, updated CMakeLists.txt to set -DWIN32, cleaned out build.qtc, reran CMake and built.
Same error pops up.

I'll try to have a closer look at how the resfile.o is assembled (going to look into windres.exe documentation) to see if this duplication would be something we can avoid in that step.

[EDIT] additional possible culprit found!
I've located a reference to resfile.o into build.qtc/mscore/CMakeFiles/mscore.dir/objects1.rsp, which is a linker response file (something I hadn't heard of before: see also GCC Wiki). This file is used to build build.qtc/mscore/CMakeFiles/mscore.dir/objects1.a (with ar.exe)

According to the logged info in build.qtc/mscore/CMakeFiles/mscore.dir/link.txt *both* objects1.a and resfile.o are then fed into g++ to create MuseScore.exe

I've got a family visit in a few minutes, so I'm not sure if I can further chase/test/patch this still today.

Do you still have an unanswered question? Please log in first to post your question.