Author Topic: windres fix  (Read 10158 times)

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
windres fix
« on: July 30, 2007, 05:03:39 pm »
I looked into the well-known space-in-path problem encountered with windres today. As it happens, the workaround is quite easy.
First, it does not seem to make sense why it should not work, using the same runtime as all the gnu tools (which all work fine). Looking at the documentation reveals: "When windres reads an rc file, it runs it through the C preprocessor first."
Aha! It seems that windres correctly removes any quotes and then calls gcc with the unquoted filename to preprocess the .rc file.

So what does the workaround look like? Easy:
    windres.exe -i "\"D:\foo bar baz\many spaces\project.rc\"" -J rc -o obj\project.res -O coff
runs without any problems.

Sure enough, this doesn't work with any other tool, the compiler will complain about the double quotes if you feed them to it. So, what needs to be done is simply a small piece of extra code in the compiler plugin, checking for windres, and either adding the extra quotes manually or giving an extra flag to QuoteStringIfNeeded.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: windres fix
« Reply #1 on: July 30, 2007, 07:10:16 pm »
So, what needs to be done is simply a small piece of extra code in the compiler plugin, checking for windres

Hmm, as far as I recall there is no such problem for quite some time. We had solved it by using the short path version of the filename (e.g. C:\SOMEPA~1\file.rc)...
Be patient!
This bug will be fixed soon...

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: windres fix
« Reply #2 on: July 30, 2007, 07:30:27 pm »
Revision 4182:

-------------- Build: default in foo ---------------
windres.exe -i "D:\foo bar baz\many spaces\project.rc" -J rc -o obj\project.res -O coff -IC:\MinGW\include
gcc: D:\foo: No such file or directory
gcc: bar: No such file or directory
gcc: baz\many: No such file or directory
gcc: spaces\project.rc: No such file or directory
gcc: warning: `-x c' after last input file has no effect
gcc: no input files
windres.exe: no resources
Process terminated with status 1 (0 minutes, 0 seconds)
1 errors, 1 warnings

"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9723
Re: windres fix
« Reply #3 on: July 30, 2007, 07:43:36 pm »
Hmm, as far as I recall there is no such problem for quite some time. We had solved it by using the short path version of the filename (e.g. C:\SOMEPA~1\file.rc)...
Notice there are systems that have short path functionality disabled (can be done in NTFS). So this isn't a very good solution anyway. (I know from other projects...)
With regards, Morten.
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 mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: windres fix
« Reply #4 on: July 30, 2007, 07:52:55 pm »
Well, you both may very well be right. I haven't used windows for quite some time anyway :).
Be patient!
This bug will be fixed soon...

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5529
Re: windres fix
« Reply #5 on: July 30, 2007, 08:30:31 pm »
was there no update in the binutils , specifally fixing this issue for windres ??

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: windres fix
« Reply #6 on: July 31, 2007, 08:37:10 am »
The description to the latest "snapshot" says that, yes... but I had not seen that one. The description of that package is a bit vague, too.

The fix mentioned here was more meant to make it work with the "current" and "candidate" releases that 99% of the people probably use.
Now what to do...? If that snapshot works, it'll probably be best for us to just ignore the issue and tell people "use the latest snapshot if it bothers you". Would save one hack in our code, at least, what do you think?

Edit: downloaded, tested, failed.

-------------- Build: default in foo ---------------
Running target pre-build steps
windres --version
GNU windres 2.17.50 20060824
Copyright 2005 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License.  This program has absolutely no warranty.
windres.exe -i "D:\foo bar baz\many spaces\project.rc" -J rc -o obj\project.res -O coff -IC:\MinGW\include
gcc: D:\foo: No such file or directory
gcc: bar: No such file or directory
gcc: baz\many: No such file or directory
gcc: spaces\project.rc: No such file or directory
gcc: warning: `-x c' after last input file has no effect
gcc: no input files
windres.exe: no resources
Process terminated with status 1 (0 minutes, 0 seconds)
1 errors, 1 warnings
« Last Edit: July 31, 2007, 08:46:56 am by thomas »
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: windres fix
« Reply #7 on: July 31, 2007, 09:07:16 am »
I believe Lieven meant the following Binutils snapshot.
Quote
http://downloads.sourceforge.net/mingw/binutils-2.17.50-20070129-1.tar.gz?modtime=1170688894&big_mirror=1

This can handle path with spaces.

But I agree with you. We should fix it. :)
Be a part of the solution, not a part of the problem.

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5529
Re: windres fix
« Reply #8 on: July 31, 2007, 09:59:29 am »
If it indeed now works out of the box, I would not put any hacks in our code. Maybe we can create a sticky post in the help forum, so we can reference to it (and also in the wiki), where we explain what to download from MinGW.

release note for the above mentioned link :
Quote
I have uploaded an update  of binutils (2.17.50-200700129-1)
to MinGW's Sourceforge File Release page. You can download it
from Snapshots section at:

https://sourceforge.net/project/showfiles.php?group_id=2435

The 2.17.50-200700129-1 snapshot incorporates modifications to official
binutils CVS since last update. In addition it patches windres to allow
use of spaces in filenames, Please refer ChangeLog entries in src for
specific changes

For more info on binutils, follow this:
http://sources.redhat.com/binutils/

Danny
« Last Edit: July 31, 2007, 10:13:38 am by killerbot »

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: windres fix
« Reply #9 on: July 31, 2007, 11:18:41 am »
I believe Lieven meant the following Binutils snapshot.
Though that one is immensely painful to find on the download page, it indeed seems to work out of the box.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline TDragon

  • Lives here!
  • ****
  • Posts: 943
    • TDM-GCC
Re: windres fix
« Reply #10 on: August 04, 2007, 03:44:58 pm »
If I remember correctly, binutils-2.17.50-20070129-1 fails to compile wxWidgets; I've stuck with 20060824.
https://jmeubank.github.io/tdm-gcc/ - TDM-GCC compiler suite for Windows (GCC 9.2.0 2020-03-08, 32/64-bit, no extra DLLs)