Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to link app manifest using clang build in MSYS2 #9603

Closed
lovettchris opened this issue Sep 15, 2021 · 7 comments
Closed

How to link app manifest using clang build in MSYS2 #9603

lovettchris opened this issue Sep 15, 2021 · 7 comments

Comments

@lovettchris
Copy link

Describe the issue

I'm trying to add the following *.rc file to my cmake library

Steps to Reproduce the Problem

  1. Add "manifest.rc" to your add_library(shell OBJECT main .cpp )
  2. Cmake and build your project.
  3. The build compiles the RC using windres, great, Building RC object shell/CMakeFiles/shell.dir/manifest.rc.obj but the linker is unhappy with it bash: line 1: C:/msys64/home/.../CMakeFiles/shell.dir/manifest.rc.obj: cannot execute binary file: Exec format error even though the file is identical to the default-manifest.o that ships with gcc.
  4. How to link a compiled resource containing an app manifest?

Additional Context: Operating System, Screenshots

If applicable, add screenshots to help explain your problem.

  • OS: [ Windows 11 Pro version 21H2 build 22000.184]
  • msys2: 20210725
  • clang: pacman -S mingw-w64-x86_64-clang
@Biswa96 Biswa96 transferred this issue from msys2/MSYS2-packages Sep 15, 2021
@Biswa96
Copy link
Member

Biswa96 commented Sep 15, 2021

Can you provide the cmake file? Generally, treat the .rc file as any other source code.

@lovettchris
Copy link
Author

attached:
test.zip

build using:

cmake .. -G "Unix Makefiles"
make

I get a different error in this little test, so not sure what is happening above for the exec format error.

Scanning dependencies of target foo
[ 33%] Building CXX object CMakeFiles/foo.dir/main.cpp.obj
[ 66%] Building RC object CMakeFiles/foo.dir/manifest.rc.obj
[100%] Linking CXX executable foo.exe
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: .rsrc merge failure: multiple non-default manifests
[100%] Built target foo

this version of ld.exe has version 2.36.1

@lazka
Copy link
Member

lazka commented Sep 16, 2021

Your example works fine here (using an updated MSYS2 though), also using ninja

@Biswa96
Copy link
Member

Biswa96 commented Sep 16, 2021

Yes, I agree with lazka. Here is the output of make command:

$ make
Scanning dependencies of target foo
[ 33%] Building CXX object CMakeFiles/foo.dir/main.cpp.obj
[ 66%] Building RC object CMakeFiles/foo.dir/manifest.rc.obj
[100%] Linking CXX executable foo.exe
[100%] Built target foo

@lovettchris
Copy link
Author

Cool , but I only install MSYS2 the other day, so which version of MSYS2 do I need?

@Biswa96
Copy link
Member

Biswa96 commented Sep 16, 2021

There is no version of msys2, just like rolling Linux distributions (e.g. ArchLinux). Make sure you have installed msys2 with latest installer and update all installed packages with pacman -Syyu command. You can search for any package details here https://packages.msys2.org/search

@lovettchris
Copy link
Author

lovettchris commented Sep 17, 2021

Ok, I ran "pacman -Syyu" and recreated my build output and I still get this warning:

C:/msys64/mingw64/bin/c++.exe -Wl,--whole-archive CMakeFiles/foo.dir/objects.a -Wl,--no-whole-archive -o foo.exe -Wl,--out-implib,libfoo.dll.a -Wl,--major-image-version,0,--minor-image-version,0 @CMakeFiles/foo.dir/linklibs.rsp
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: .rsrc merge failure: multiple non-default manifests

but it does produce a binary and the binary has one .rsrc section containing my updated manifest so all good, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants