Author Topic: How to get Windows Resources to compile and link with C::B and MinGW?  (Read 5513 times)

FLMason

  • Guest
Hi Everyone,
   An old mainframe programmer here, trying the new stuff.

I'm working through a Windows API tutorial and am attempting a DialogBox... which needs a Windows Resource (.rc) apparently.

In trolling around the web, seems like a Windows Resource Compiler is required. I found some old screen shots that seem to show a Resource Compiler Directory Window in older versions of C::B.

However, this doesn't appear in my Compiler Window.

So can anyone point to me info on how to obtain, and install a Windows Resource Compiler?

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9723
Re: How to get Windows Resources to compile and link with C::B and MinGW?
« Reply #1 on: February 19, 2008, 08:46:28 am »
So can anyone point to me info on how to obtain, and install a Windows Resource Compiler?
A Windows resource compiler comes with the GCC (MinGW) compiler suite for Windows. It's called "windres.exe" Besides the usual compiler setup you shouldn't need anything special. "windres.exe" is setup as the default resource compiler for C::B. Of course you need to add the RC file to your project to get C::B compile and link it.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline severach

  • Multiple posting newcomer
  • *
  • Posts: 44
Re: How to get Windows Resources to compile and link with C::B and MinGW?
« Reply #2 on: February 29, 2008, 04:00:54 am »
Add the resource to your project and CodeBlocks will include it in the compile. MinGW provides windres.exe as the resource compiler. Some Microsoft compilers require you to download the SDK to get the resource compiler. Other compilers include their own resource compilers.

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: How to get Windows Resources to compile and link with C::B and MinGW?
« Reply #3 on: February 29, 2008, 08:14:45 am »
Please do note that windres has to be able to call gcc sometimes (for preprocessing).
If you happen to use the gcc 4.2.1 version of MinGW, then you should copy (or hardlink, if you use XP/Vista) mingw32-gcc-DW2 (or -SJLJ) to gcc, else windres will fail. You can do that for all of the mingw32-foobar-DW2/SJLJ programs for simplicity, but gcc is necessary if you want to use windres.

In the older 3.4 build, MinGW team has already done that, but it seems that this was forgotten in the 4.2.1 build. It isn't a big issue, but it's one thing that can be the cause of many headaches, as the error "CreateProcess failed (Error 0)" is not really helpful if you don't know...
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline Sledgehammer_999

  • Single posting newcomer
  • *
  • Posts: 4
Re: How to get Windows Resources to compile and link with C::B and MinGW?
« Reply #4 on: March 02, 2008, 01:28:08 am »
thank you thomas. I was about to ask here because it failed to compile the "example wxwidget project" when trying to compile resource.rc with the error "preprossecing failed"