Code::Blocks Forums

User forums => Help => Topic started by: Mr_Poletski on December 19, 2012, 07:34:42 am

Title: Fresh Win 32 GUI project will not compile
Post by: Mr_Poletski on December 19, 2012, 07:34:42 am
I've searched on here and not found my issue and this is annoying the hell out of me.

I've been an int main void man for ages, now I am trying to evolve into an int winmain void man now.

I have an application I want to adapt from, basically a dos app into a windows app with proper dialogues etc, rather than one I have to put files in the right place, pull the level and my program do it's business.

So I get code blocks, Create a brand new project 'win32 gui project'. Wonder what I am starting with, hit compile and get this:

Code
mingw32-g++.exe -Wall  -O2  -Wall -g -DUNICODE    -c "C:\Documents and Settings\my_login\My Documents\C\WinTruBack\main.cpp" -o obj\Release\main.o
C:\Documents and Settings\my_login\My Documents\C\WinTruBack\main.cpp: In function 'int WinMain(HINSTANCE, HINSTANCE, LPSTR, int)':
C:\Documents and Settings\my_login\My Documents\C\WinTruBack\main.cpp:20:27: error: cannot convert 'char [21]' to 'LPCWSTR {aka const wchar_t*}' in assignment
C:\Documents and Settings\my_login\My Documents\C\WinTruBack\main.cpp:53:12: error: cannot convert 'char*' to 'LPCWSTR {aka const wchar_t*}' for argument '2' to 'HWND__* CreateWindowExW(DWORD, LPCWSTR, LPCWSTR, DWORD, int, int, int, int, HWND, HMENU, HINSTANCE, LPVOID)'
Process terminated with status 1 (0 minutes, 0 seconds)
2 errors, 0 warnings (0 minutes, 0 seconds)

I find it hard to believe the default program template wont even compile. I fully expect it to run and then do sod all, but I can't even run it. I must be doing something wrong right? I just got 12.11, but it was doing the same thing for me on 10.5
Title: Re: Fresh Win 32 GUI project will not compile
Post by: MortenMacFly on December 19, 2012, 08:06:13 am
This is not a general programming forum. Please respect the forum rules you agreed to when registering, if you forgot, read the rules again here:
http://forums.codeblocks.org/index.php/topic,9996.0.html
Topic locked.
Title: Re: Fresh Win 32 GUI project will not compile
Post by: MortenMacFly on December 19, 2012, 06:00:35 pm
But I was not asking for general programming help.
Well it is... in the end. The default projects are provided for convenience and only a starter. But they are not guaranteed to work as they (for example) heavily depend on the compiler you use which is out of our control. The project you use was designed for the VC compiler to my knowledge. It seems you are using GCC right?

I would recommend try at the command line first, or simply replace the code with the one of other resources and probably change the project setup accordingly. Why do you insist on using WinMain at all? I fail to see a reason to do so.

Edit: Unlocked again so you don't send me PM's, please.
Title: Re: Fresh Win 32 GUI project will not compile
Post by: Biplab on December 19, 2012, 06:54:15 pm
@Morten,

This is a Bug in Win32 project wizard. Wizard generated code is good for Ansi build only. However OP is trying to build a Unicode version which will eventually fail. I will fix it tomorrow.


@Mr_Poletski ,

File a bug report in Berlios.
Title: Re: Fresh Win 32 GUI project will not compile
Post by: Jenna on December 19, 2012, 10:45:55 pm
On XP the default project works fine without modifications using TDM gcc 4.7 as compiler.

Can it try to use unicode without modifications?
Title: Re: Fresh Win 32 GUI project will not compile
Post by: Biplab on December 20, 2012, 06:19:44 am
Can it try to use unicode without modifications?

No, it is not possible to compile project wizard generated code in Unicode build. Generated code uses char* for strings which is not allowed in Unicode build.
Title: Re: Fresh Win 32 GUI project will not compile
Post by: Jenna on December 20, 2012, 06:24:33 am
Can it try to use unicode without modifications?

No, it is not possible to compile project wizard generated code in Unicode build. Generated code uses char* for strings which is not allowed in Unicode build.
I know.
I think I was not clear enough.
I meant:
is it possible, that the OP compiles the default project in unicode mode without changing it (or the global compiler settings) ?
Because with default settings (of win, gcc and the wizard) it compiles fine.
Title: Re: Fresh Win 32 GUI project will not compile
Post by: Biplab on December 20, 2012, 06:31:18 am
I know.
I think I was not clear enough.
I meant:
is it possible, that the OP compiles the default project in unicode mode without changing it (or the global compiler settings) ?
Because with default settings (of win, gcc and the wizard) it compiles fine.

At the moment default project template is suitable for Ansi build only. However it is easy to change it to build it in Unicode mode. Just define UNICODE and _UNICODE in project build option.

I intend to make it even newbie proof. I want to change project wizard to generate 4 build targets (Ansi-Debug, Ansi-Release, Unicode-Debug & Unicode-Release). This way user can select appropriate target and build without any hiccup.
Title: Re: Fresh Win 32 GUI project will not compile
Post by: Jenna on December 20, 2012, 07:57:48 am
At the moment default project template is suitable for Ansi build only. However it is easy to change it to build it in Unicode mode. Just define UNICODE and _UNICODE in project build option.
That means the OP must have changed someting, either in the project settings or in the global compiler options.
I asked because he asked whether he might have made a mistake:
I find it hard to believe the default program template wont even compile. I fully expect it to run and then do sod all, but I can't even run it. I must be doing something wrong right? I just got 12.11, but it was doing the same thing for me on 10.5
Title: Re: Fresh Win 32 GUI project will not compile
Post by: Mr_Poletski on December 20, 2012, 09:09:08 am
I believe this happened because I had a previous copy of cb installed where I had some compiler options set, including unicode. I don't think the compiler options stayed when I upgraded (old 10.5 to 12.11), but unicode had.

Thanks for the help guys, I can get writing now.