I'm trying to link a resource file with mingw. I went to mingw's site, read this tutorial:
But, for making a .c / .cpp file into a .o, it doesnt work. And when I try linking my .o & .cpp, it deletes my cpp file! (Had to make a backup one -,-) I've tried this six times, it does the same thing each timeHere's an example. The following is a code sample for a simple Windows program. Cut and paste it into a file named hello.c to try it out.
If you want to create a Windows executable hello.exe, from a c file called hello.c, try the following:Code:#include <windows.h> int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow) { MessageBox (NULL, "Hello", "Hello Demo", MB_OK); return (0); }
This compiles hello.c into an object file, hello.oCode:gcc -c hello.c
This creates an executable hello.exe from hello.o The -mwindows switch is needed to create Windows executables instead of console applications. It assures the appropriate Windows libraries are linked in for you. To get a console screen along with a standard windows application, add the -mconsole flag as well as -mwindows.Code:gcc -o hello hello.o -mwindows
If you have resources from a resource file (.rc) that also need to be added to your executable, you'll need to compile the resource file as well as your other source files and include the compiled resources when linking to create the executable. Here's an example that shows how to compile and link in a resource file named resfile.rc.
Code:windres -o resfile.o resfile.rc gcc -o hello hello.o resfile.o -mwindows
Likewise when I specify a directory for hello.o. Is this bad documentation or am I just a retard? -,-.Code:$ g++ -o hello hello.o -mwindows g++.exe: hello.o: No such file or directory g++.exe: no input files



LinkBack URL
About LinkBacks


