Interesting one here; how do I go about including a .rc file in a makefile for compiling? Here's my newbie makefile:
| 1 | # Generic Makefile. |
| 2 | TEMP = $(wildcard *.cpp) |
| 3 | FILES = $(if $(TEMP), $(TEMP), $(error No source code found!)) |
| 4 | OBJS = $(addsuffix .o, $(basename $(FILES))) |
| 5 | |
| 6 | # binary name |
| 7 | BINARY = GameTest5.exe |
| 8 | |
| 9 | # compiler flags |
| 10 | FLAGS = -Wall -O2 -s -ffast-math -fomit-frame-pointer -funroll-loops |
| 11 | |
| 12 | # main rule; compiles and links everything |
| 13 | $(BINARY) : $(OBJS) |
| 14 | $(CXX) -o $(BINARY) $(OBJS) $(FLAGS) -lalleg -llua |
| 15 | |
| 16 | $(OBJS) : *.h |
So where and how does the resource file go
Well, never used resourcee files, but if you want to compile too, add it to the temp var...
But I'm level 0 in makefiles....
It should look something like
myresource.o : myresource.rc windres [parameters] -o $< $^
Or something like that. Check Allegro makefile, which uses one in the demo example. I am at work, and don't have that, but it is like any other program.
If it were me, I'd
| 1 | # Generic Makefile. |
| 2 | TEMP = $(wildcard *.cpp) |
| 3 | FILES = $(if $(TEMP), $(TEMP), $(error No source code found!)) |
| 4 | OBJS = $(FILES:.cpp=.o) |
| 5 | # or is it .o=.cpp I can never remember :( |
| 6 | |
| 7 | # binary name |
| 8 | BINARY = GameTest5.exe |
| 9 | |
| 10 | #libs |
| 11 | LDLIBS=-lalleg -llua |
| 12 | |
| 13 | # compiler flags |
| 14 | CXXFLAGS = -Wall -O2 -ffast-math -fomit-frame-pointer -funroll-loops |
| 15 | LDFLAGS= -s |
| 16 | |
| 17 | # main rule; compiles and links everything |
| 18 | all: $(BINARY) |
| 19 | |
| 20 | $(BINARY) : $(OBJS) |
| 21 | $(LINK.o) -o $(BINARY) $(OBJS) $(LDLIBS) |
| 22 | |
| 23 | $(OBJS) : *.h |
I have
RESOURCE = obj/mingw/resource.o ... GOBJS += $(RESOURCE) ... $(RESOURCE): src/resource.rc gfx/game.ico windres -O coff -o $@ -i $< $(EXEF): $(GOBJS) $(CC) $(CFLAGS) $(LFLAGS) $(GOBJS) -o $@ $(LIBS)
You will probably want the windres line.
Speaking of mingW:
Why has the latest version renamed executables for make, gcc and g++?
Why has the latest version renamed executables for make, gcc and g++?
They're no longer called make, gcc and g++?
What are they called now?
I don't know but I would like to know very much, because it has screwed up my GNE installer program on MingW2.
Edit: Evert: I know that make is now "make-mingw32.exe". I didn't think g++ had changed? But several of the items were renamed to append -mingw32 to their filenames.
That sucks. Badly.
It means all my makefiles are broken for newer versions of MinGW. Will the tools work if you rename them?
Yes. That's what I did personally, and what I've told all of my programming friends to do (well at first I told them to copy the file so that it has both names). It's really lame imho. It works perfectly fine to rename the stuff.
With this and the whole including windows.h with the standard header files and I'm extraordinarily dissapointed with the MingW 2.0 release. The GCC 3.2 compiler is awesome, but now I have to do 2 workarounds to compile Allegro code, because you have to define that lame _GTHREAD_HIDE_API or whatever symbol to get rid of the windows.h.
I simply copied the make file and renamed the copy.
But for some reason allegro doesn't compile anymore.. Guess I need to make a clean install of everything (ming, allegro, fblend)
On a sensible OS you'd symlink make to make-mingw32 
Pete
Guess I need to make a clean install of everything (ming, allegro, fblend)
especially if you use C++. 3.1, 3.0 and 2.95.* all use a different method to munge variable names. (none are compatible)
Okay, I'm taking another stab at this. Makefile syntax has always eluded me, so this is really frustrating
What have I done wrong here? I get "Makefile:7: *** missing seperator. Stop." Dunno what a seperator is though ....
| 1 | # Generic Makefile. |
| 2 | SRCS = $(wildcard *.cpp) |
| 3 | FILES = $(if $(SRCS), $(SRCS), $(error No source code found!)) |
| 4 | OBJS = $(addsuffix .o, $(basename $(FILES))) |
| 5 | |
| 6 | Rsrc.o : rsrc.rc |
| 7 | windres -O coff -o $< $^ |
| 8 | |
| 9 | # binary name |
| 10 | BINARY = AllegroPaintviamakefile.exe |
| 11 | |
| 12 | # compiler flags |
| 13 | FLAGS = -Wall -O2 -s -ffast-math -fomit-frame-pointer -funroll-loops -mwindows -O1 -fexpensive-optimizations |
| 14 | |
| 15 | # main rule; compiles and links everything |
| 16 | $(BINARY) : $(OBJS) |
| 17 | $(CXX) -o $(BINARY) $(OBJS) $(FLAGS) -lalleg -llua |
| 18 | |
| 19 | |
| 20 | # lets the makefile know what headers the objects require. |
| 21 | # If one changes, everything that includes it recompiles. |
| 22 | # Here, if any header changes, everything is recompiled |
| 23 | $(OBJS) : *.h |
Make sure it's a [TAB]:
Rsrc.o: rsrc.rc
[TAB]windres -O coff -o $< $^
Whoops. Thanks.
I had some more fubarness but I think I got it now ...
| 1 | # Generic Makefile. |
| 2 | SRCS = $(wildcard *.cpp) |
| 3 | FILES = $(if $(SRCS), $(SRCS), $(error No source code found!)) |
| 4 | OBJS = $(addsuffix .o, $(basename $(FILES))) |
| 5 | |
| 6 | # binary name |
| 7 | BINARY = AllegroPaint.exe |
| 8 | |
| 9 | # compiler flags |
| 10 | FLAGS = -Wall -O2 -s -ffast-math -fomit-frame-pointer -funroll-loops -mwindows -O1 -fexpensive-optimizations |
| 11 | |
| 12 | # main rule; compiles and links everything |
| 13 | $(BINARY) : $(OBJS) Rsrc.o |
| 14 | $(CXX) -o $(BINARY) $(OBJS) $(FLAGS) -lalleg -llua |
| 15 | |
| 16 | Rsrc.o : rsrc.rc |
| 17 | windres -O coff -o $< $^ |
| 18 | |
| 19 | # lets the makefile know what headers the objects require. |
| 20 | # If one changes, everything that includes it recompiles. |
| 21 | # Here, if any header changes, everything is recompiled |
| 22 | $(OBJS) : *.h |
Seems to work
I have no idea what "$< $^" is supposed to mean though ....
EDIT: Scratch that ....
windres -O coff -o rsrc.rc rsrc.rc windres: rsrc.rc:1: parse error \DEV-CPP\BIN\..\lib\gcc-lib\mingw32\2.95.3-6\cpp0.exe: stdout: Broken pipe C:\DEV-CPP\BIN\MAKE.EXE: *** [Rsrc.o] Error 1
Your rc file is fubar'ed.
windres: rsrc.rc:1: parse error
I have no idea what "$< $^" is supposed to mean though
That you could find by RTFMing
The make manual is fairly logical. Check google for an online one.
I have looked through it; it breaks my brain. And my .rc file should be just peachy; Dev-C++ compiles it fine ...
EDIT: DAMMIT!!!

Running that makefile totally ruined my resource file!!! Now I have to rewrite the whole bloody thing ....
I think you need to set the type of the input and output files... heres the line that I use...
windres -F pe-i386 -I rc -O COFF -i input.rc -o output.o
If you need to know what any of that means:
C:\blah>windres --help
Well, I had copied my dialog scripts into my dialog-making notes, so that wasn't too much work (whew). Anyway, "windres --help" = "crapload of text that whizzes by and I can't read it". Maybe I'll go dig up the make docs and see if I can't figure out a little more. See if I can decipher your little line there .....
um... 23.. You just redirect all that to a file, or get 'less'. Then do: 'windres --help | less'. Then less will 'page' the program, and let you scoll the text up and down.
I used your line, slightly modified:
rsrc.o : rsrc.rc windres -F pe-i386 -I rc -O COFF -i rsrc.rc -o rsrc.o
It compiles, but all the resources are missing in the program. No dialogs, no menus, no cursors, etc. I'm reading the make docs now, but my main curiosity is what's supposed to "compile" the resource file. It's not exactly standard C/C++ ...
I tried this line too; same result:
windres --use-temp-file -I rc -O coff -i rsrc.rc -o rsrc.o
Just trying random stuff until I find the info in the docs ...
I know it works for me
How are you using the resources?
Reply 23 ....
Never mind; I got it. Look at the complete makefile I posted up there; I put rsrc.o in the prerequisites, but I didn't actually link it in the command. Here's my final effort:
| 1 | SRCS = $(wildcard *.cpp) |
| 2 | FILES = $(if $(SRCS), $(SRCS), $(error No source code found!)) |
| 3 | OBJS = $(addsuffix .o, $(basename $(FILES))) |
| 4 | |
| 5 | # binary name |
| 6 | BINARY = BOLA.exe |
| 7 | |
| 8 | # compiler flags |
| 9 | FLAGS = -Wall -O2 -s -ffast-math -fomit-frame-pointer -funroll-loops -mwindows |
| 10 | |
| 11 | # main rule; compiles and links everything |
| 12 | $(BINARY) : $(OBJS) rsrc.o |
| 13 | $(CXX) -o $(BINARY) $(OBJS) rsrc.o $(FLAGS) -lalleg |
| 14 | |
| 15 | rsrc.o : rsrc.rc |
| 16 | windres rsrc.rc -o rsrc.o |
| 17 | |
| 18 | # lets the makefile know what headers the objects require. |
| 19 | # If one changes, everything that includes it recompiles. |
| 20 | # Here, if any header changes, everything is recompiled |
| 21 | $(OBJS) : *.h |
By jove, I think I've got it ....