Link to home
Start Free TrialLog in
Avatar of kh5395
kh5395

asked on

Unicode and MFC

I am looking at a Novell sample program written in C but being compiled on the MSVC++ ver 6 compiler. I am getting an error message such as :-

Libcd.lib(wwincrt0.obj) : error LNK2001: unresolved external symbol _wWinMain@16

which I believe to be due to mixing Unicode and MFC. However  I am using the win32 Application wizard to generate my project not the MFC App wizard.

I have also tryed adding "wWinMainCRTStartup" to the Project|Settings|Link|Output|Entry-Point Symbol edit box, but this made no difference.

Does anyone have any ideas as to a solution?
Thanks
Avatar of nil_dib
nil_dib

Unicode should be no problem for MFC ....
concerning the linker problem refer to
https://www.experts-exchange.com/Q.10190192
Avatar of kh5395

ASKER

I have looked at Q.10190192 and nothing I try seems to work.

If I was to use just a C program would I be able to compile it as a win32 application or would it have to be done as a Win32 consol application?

Thanks for your help.
ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
CAUSE
A project of type Application is a Windows-based application, so it requires the WinMain function as the entry point.

RESOLUTION
Create a new project and select Console Application as the Project Type,
OR add a project to the existing Project.

To Create a new target for an existing project with Visual C++ 2.x, from the Project menu, choose Targets, and select New. Enter a Target Name, and choose Win32 Console Application as the type. To build the new target, move to the project dialog box, change the Target to your new Target name, and rebuild.

To add a project with Visual C++ 5.0, select Project, then Add to Project, and select New. Click on the Projects tab and select Win32 Console Application.

I THINK THIS HAS TO WORK
>which I believe to be due to mixing Unicode and MFC. However  I am using the win32 Application wizard to generate my project not the MFC App wizard.

So, you are using MFC. Then, the project setting should be either "Use MFC in a Shared DLL" or "Use MFC in a Static Library".
>>Then, the project setting should be either "Use MFC in a
>>Shared DLL" or "Use MFC in a Static Library".

Agree with chensu - nevertheless, the UNICODE 'wWinMain()' must be exported using C naming conventions...
Avatar of kh5395

ASKER

The project works if it is compiled as a win32 console application, but I still can't get it to work with a win32 app.

The project settings are set to "Use MFC in a Static Library" as I'm using .LIB files.

I don't quite understand the extern "C" bit entirely. My code does not contain WinMain() or WndProc() procedures. Is this where the problem is ?
>>My code does not contain WinMain() or WndProc()
>>procedures. Is this where the problem is ?

I assume that's the problem. Are you using 'wmain()' instead? If so (and if you want to make it a console app,)change the linker switch '/subsystem:windows' to read '/subsystem:console'. If you want to make it a GUI (i.e. windows) app, you'll have to use a 'wWinMain()' entry point.

Avatar of kh5395

ASKER

>>If you want to make it a GUI (i.e. windows) app, you'll have to use a
       'wWinMain()' entry point.

Will this happen by default or do you have to change the Project|Settings|Link|Output|Entry-Point to wWinMain?
>>Will this happen by default

You don't have to set the entry point manually (there are rare exceptions when it's necessary to do this). The linker will automatically search for 'wWinMain()' when UNICODE is specified, as it searches for 'wmain()' in case of console application.
For Unicode, you must set "wWinMainCRTStartup" as the entry-point under Project|Settings|Link|Output|Entry-Point.

I am working on a Unicode project right now, and that is the entry-point I am using, and my program is working just fine.

For further reference, consult:

msdn.microsoft.com/library/devprods/vs6/vc++/vccore/_core_unicode_programming_summary.htm
Avatar of kh5395

ASKER

The problem seems to be solved using wWinMain as the entry point.

Thanks for your help.