![]() |
|
Linking with resource files in MinGW |
aybabtu
Member #2,891
November 2002
|
I apparently need to do this to use dialogs in my programs...but I can't figure out how to link with them. Thanks! |
23yrold3yrold
Member #1,134
March 2001
![]() |
windres rsrc.rc -o rsrc.o
Then link with rsrc.o like all other object files. -- |
aybabtu
Member #2,891
November 2002
|
Okay...I'm not sure how to do that...usually I do this: g++ -s -mwindows -O2 -O3 winwolf.cpp -o winwolf.exe -lalleg So, I'm guessing I'd stick rsrc.o in between the -o and winwolf.exe? (I'm not going to use resources for winwolf, this is just hypothetical.) |
23yrold3yrold
Member #1,134
March 2001
![]() |
I dunno; I've never been real sharp on the layout of that compile line -- |
Monolith Tyriss
Member #2,523
July 2002
|
Yup. You put the rsrc.o file in after the -o option but before the .exe option. If I remember right anyway, -o is putting everything together, so adding rsrc.o in after -o is telling the compiler to put that object with the result of winwolf.cpp together into winwolf.exe. I'm not sure that's how it works, given that I haven't used a gcc command line in 2 or 3 years, but I think that's what you need. :} |
X-G
Member #856
December 2000
![]() |
Monolith: NOOO -o xxxx sets gcc's output file to be xxxx. 23 got it right, but what he REALLY should do is compile all the .cpp files and then link the .o files together. -- |
23yrold3yrold
Member #1,134
March 2001
![]() |
Quote: 23 got it right, but what he REALLY should do is compile all the .cpp files and then link the .o files together. That's what I said (twice) # main rule; compiles and links everything $(BINARY) : $(OBJS) rsrc.o $(CXX) -o $(BINARY) $(OBJS) rsrc.o $(FLAGS) # the rule that handles the resource file/object rsrc.o : rsrc.rc windres rsrc.rc -o rsrc.o # compiles all .cpp files %.o : %.cpp *.h $(CXX) -o $@ -c $< -gstabs
-- |
X-G
Member #856
December 2000
![]() |
You didn't actually SAY that, though. -- |
aybabtu
Member #2,891
November 2002
|
Okay. This is what I'm gonna do: //Type my file.cpp! //Type my filerc.rc! //Or in the other order... >windres filerc.rc -o filerc.o >g++ -s -mwindows -O2 -O3 file.cpp -o file.exe Now, this is the code I want to use. Can I link with resources in that second commandline? Or do I have to separate the compiler/linker commands? EDIT: Whoa...you beat me...TWICE! |
Carrus85
Member #2,633
August 2002
![]() |
One suggestion-- don't use windows dialogs. It ruins the cross compatability between windows and linux. What exactly are you using the dialogs for anyway?
|
X-G
Member #856
December 2000
![]() |
23, show him your generic makefile that automatically generates object targets from every .cpp file in the directory. Oh, and supplying both -O2 and -O3 on the same commandline seems ... redundant at least. -- |
23yrold3yrold
Member #1,134
March 2001
![]() |
aybabtu: that doesn't link in the resource file Compile the rsrc.rc file, then the source code, then link them all. Three lines, like I posted above. Here's the whole makefile at X-G's request:
I'm constructing this out of one makefile that uses proper flags and another that compiles a resource file, so let's hope this works ... and why would you use the command line over a makefile? Do you like typing out three lines (error free, I hope) every time you compile? -- |
aybabtu
Member #2,891
November 2002
|
Carrus: I'm learning the Win API...I thought I would since I now have a windows compiler! GEEZ! Slow down people! |
X-G
Member #856
December 2000
![]() |
You might want to fix up that linking line though - I doubt you'll want Lua all the time. -- |
23yrold3yrold
Member #1,134
March 2001
![]() |
aybabtu said: tell me where to stick filerc.o! X-G: I know, I was still working on it ... how's it now? -- |
aybabtu
Member #2,891
November 2002
|
The question is now: |
Carrus85
Member #2,633
August 2002
![]() |
Learning the windows API is ok, just don't corrupt your winwolf project with foreign propretary windows "devils", so no one can test in on linux.
|
aybabtu
Member #2,891
November 2002
|
Yay! I got it! I did this: g++ -s -mwindows res.cpp resrc.o -o res.exe Yay! My program has an icon! Kewl...now I've just gotta continue on with my tutorial! |
|