对于windows的RC文件用GCC编译也是很EASY的,
windres
这个GNU Binary Utility是个非常有用的工具,我们只要windres -i resource.rc -o resource.o即可生成GCC可用的库,于是在gcc -o dialog dialog.c resource.o -mwindows就可以了。下面是来自http://ftp.gnu.org/old-gnu/Manuals/binutils-2.12/html_node/binutils_14.html的摘录:
12. windres
windres
may be used to manipulate Windows resources.
Warning:
windres
is not always built as part of the binary utilities, since it is only useful for Windows targets.
windres [options] [input-file] [output-file] |
windres
reads resources from an input file and copies them into an output file. Either file may be in one of three formats:
-
A text format read by the Resource Compiler.
-
A binary format generated by the Resource Compiler.
- A COFF object or executable.
rc
res
coff
The exact description of these different formats is available in documentation from Microsoft.
When windres
converts from the rc
format to the res
format, it is acting like the Windows Resource Compiler. When windres
converts from the res
format to the coff
format, it is acting like the Windows CVTRES
program.
When windres
generates an rc
file, the output is similar but not identical to the format expected for the input. When an input rc
file refers to an external filename, an output rc
file will instead include the file contents.
If the input or output format is not specified, windres
will guess based on the file name, or, for the input file, the file contents. A file with an extension of `.rc' will be treated as an rc
file, a file with an extension of `.res' will be treated as a res
file, and a file with an extension of `.o' or `.exe' will be treated as a coff
file.
If no output file is specified, windres
will print the resources in rc
format to standard output.
The normal use is for you to write an rc
file, use windres
to convert it to a COFF object file, and then link the COFF file into your application. This will make the resources described in the rc
file available to Windows.
-
The name of the input file. If this option is not used, then
windres
will use the first non-option argument as the input file name. If there are no non-option arguments, thenwindres
will read from standard input.windres
can not read a COFF file from standard input. -
The name of the output file. If this option is not used, then
windres
will use the first non-option argument, after any used for the input file name, as the output file name. If there is no non-option argument, thenwindres
will write to standard output.windres
can not write a COFF file to standard output. -
The input format to read.
format may be
`res' ,
`rc' , or
`coff' . If no input format is specified,
windres
will guess, as described above. -
The output format to generate.
format may be
`res' ,
`rc' , or
`coff' . If no output format is specified,
windres
will guess, as described above. -
Specify the BFD format to use for a COFF file as input or output. This is a BFD target name; you can use the
`--help' option to see a list of supported targets. Normally
windres
will use the default format, which is the first one listed by the `--help' option. 15.1 Target Selection . -
When
windres
reads anrc
file, it runs it through the C preprocessor first. This option may be used to specify the preprocessor to use, including any leading arguments. The default preprocessor argument isgcc -E -xc-header -DRC_INVOKED
. -
Specify an include directory to use when reading an
rc
file.windres
will pass this to the preprocessor as an `-I' option.windres
will also search this directory when looking for files named in therc
file. -
Specify a
`-D' option to pass to the preprocessor when reading an
rc
file. -
Enable verbose mode. This tells you what the preprocessor is if you didn't specify one.
-
Specify the default language to use when reading an
rc
file. val should be a hexadecimal language code. The low eight bits are the language, and the high eight bits are the sublanguage. -
Use a temporary file to instead of using popen to read the output of the preprocessor. Use this option if the popen implementation is buggy on the host (eg., certain non-English language versions of Windows 95 and Windows 98 are known to have buggy popen where the output will instead go the console).
-
Use popen, not a temporary file, to read the output of the preprocessor. This is the default behaviour.
-
Prints a usage summary.
-
Prints the version number for
windres
. -
If
windres
is compiled withYYDEBUG
defined as1
, this will turn on parser debugging. -
-
-i filename
--input filename
-o filename
--output filename
-I format
--input-format format
-O format
--output-format format
-F target
--target target
--preprocessor program
--include-dir directory
-D target
--define sym [=val ]
-v
--language val
--use-temp-file
--no-use-temp-file
--help
--version
--yydebug