User forums > Using Code::Blocks
Using Code::Blocks to make DirectX program
(1/1)
Glooper:
Hi All,
I am trying to compile a DirectX program by using the project wizard in Code::Blocks. I have set up all the paths to the libraries and the global variables as found in a short tutorial, but I am getting the following error when I try to compile:
k:\mingw\bin\..\lib\gcc\mingw32\4.5.2\..\..\..\libmingw32.a(main.o):main.c undefined reference to `WinMain@16'
I've set the -mwindows option in Project->Build Options->Linker Settings, which I found by Googling, but I still get the error.
Any suggestions?
MortenMacFly:
Well, did you check the obvious, whether you do have a main function and you compile link it?
Without code it'll be very hard to help. Try to strip down the project to a minimal sample which you can attach here.
Glooper:
As I said in my post, I used the Code::Blocks Project Wizard to create the project, so yes it does have a WinMain and it is a minimal application. It compiles fine, the error is from the linker.
stahta01:
Turn on full compiler logging
http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F
And since the code is short, please post it in code tags!
Tim S.
Glooper:
It's OK, I've sorted it now.
It seems to be a problem with the DirectX9 wizard. The wizard generated code assumes a UNICODE build, but the project build options are set to _MBCS. I changed all references to unicode text in the main.cpp file then got the original undefined reference error. I then noticed an error in the WinMain line:
--- Code: ---
Original line:
INT WINAPI wWinMain( HINSTANCE hInst, HINSTANCE, LPWSTR, INT ) <== used when building Unicode
New line:
INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR, INT ) <== used for MBCS
--- End code ---
Now it builds/links and runs fine.
Navigation
[0] Message Index
Go to full version