Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1014355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:14:29+00:00 2026-05-16T10:14:29+00:00

In theory, it’s very easy to build a Win32 app with a resource file

  • 0

In theory, it’s very easy to build a Win32 app with a resource file using cmake. In an add_executable command, a resource file can be listed as easily as a C or C++ source file. There is a known bug, however, when building using MinGW tools.

I found a workaround, which is to include the following in CMakeFiles.txt…

if(MINGW)
  set(CMAKE_RC_COMPILER_INIT windres)
  ENABLE_LANGUAGE(RC)
  SET(CMAKE_RC_COMPILE_OBJECT
      "<CMAKE_RC_COMPILER> <FLAGS> <DEFINES> -o <OBJECT> <SOURCE>")
endif(MINGW)

Unfortunately, this doesn’t seem to work. What seems to happen is that windres generates a <whatever>.rc.res file which ld doesn’t understand.

In my searches, I’ve developed a strong suspicion that Win32 support is seen as a very low priority, especially outside of Visual Studio. This is understandable, as Win32 obviously isn’t as important as it once was. And of course Visual Studio Express Editions are easily available for free.

Even so, it would be convenient for me if I could use MinGW GCC for a few old Win32 apps I still use. If nothing else, I can get GCOV test coverage stats.

Obviously if all else fails, I could always handle resource files using a custom build command. One issue is that I’m not familiar with either windres or ld, or how MinGW is meant to handle Win32 resource files. Another is that I don’t really want to reinvent the wheel if someone already has a superior wheel they’d like to share with me.

So that’s basically it – how can I support building Win32 apps with resource files using cmake, and using MinGW (but not breaking support for Visual Studio)?

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T10:14:30+00:00Added an answer on May 16, 2026 at 10:14 am

    I think, your problem is here:

    <CMAKE_RC_COMPILER> <FLAGS> <DEFINES> -o <OBJECT> <SOURCE>
    

    Maybe you should write something like this:

    <CMAKE_RC_COMPILER> <SOURCE> <OBJECT>
    

    Or more formal:

    <CMAKE_RC_COMPILER> -i <SOURCE> -o <OBJECT>
    

    The other possible problem could be with – which extension does cmake substitutes? As windress will guess the needed output file format from that.

    References are here:
    http://www.mingw.org/wiki/MS_resource_compiler

    “res” files are unappropriate for ld, as you already know, and the windres example
    sourceware.org/binutils/docs/binutils/windres.html

    windres man

    EDIT by question author…

    The fixed cmake code snippet is as follows…

    if(MINGW)
      set(CMAKE_RC_COMPILER_INIT windres)
      ENABLE_LANGUAGE(RC)
      SET(CMAKE_RC_COMPILE_OBJECT
        "<CMAKE_RC_COMPILER> <FLAGS> -O coff <DEFINES> -i <SOURCE> -o <OBJECT>")
    endif(MINGW)
    

    It should probably be setting a flags variable rather than inserting the -O option in the command template, but this works.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this theory, I can grab the file size using fseek and ftell
In theory this seems easy but I just can't get my head around this...
In theory in layered architecture you can have multiple modules on the same layer.
I understand the theory behind the factory design pattern now, but can't seem to
easy theory question. I have a couple years experience with PHP and Javascript, trying
I'm studying computability theory, and I'm looking for a problem that clearly can be
Language used: C# Theory: I want to create a file with the flag FileOptions.DeleteOnClose
I'm studying information theory but one thing I can't seem to work out. I
Theory: One of the things that appeals to me about node.js is using it
In theory, can I write a game for iOS in openGL ES and expect

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.