Question

I'm a beginner for Visual Studio 2008 (32-bit). The WinCE version I'm using is 7.0 Evaluation. I created a new project as,

New Project -> Platform Builder-> OS Design

Selected the BSP as,

BSP: Generic CEPC:x86

When the design template highlighted Consumer Media Device, I just clicked Finish.

The above selections are a must for me. Besides these, I created a subproject as a simple hello world application and added a line cout<<"Hello World"; (as they are by default cpp files). I also included iostream.

I got errors such as,

fatal error C1083: Cannot open include file: 'iostream': No such file or directory

As stated in this link, I checked out for libcmtd.lib and it is in the $(VCInstallDir)lib. It is also included in Tools | Options | Projects and Solutions | VC++ Directories | Show Directories For -> Library files.

Based on this link, I checked the precompiled header settings. I found the following there:

Precompiled Files : Yes
Precompiled Header File Name : StdAfx.pch
Precompiled Header Object File Name : StdAfx.obj
Precompiled Header Options : (blank)
Precompiled Header Source File Name : StdAfx.h

How do I disable this? In case if I disable this, won't I get any other problems for the other part of the project?

Update:

For a C program,

#include<stdio.h>

int main()
{
    printf("\nHello World\n");
    return 0;
}

I got the following errors,

error LNK2019: unresolved external symbol _WinMain referenced in function _WinMainCRTStartupHelper 

fatal error LNK1120: 1 unresolved externals 

fatal error U1077: 'D:\WINCE700\sdk\bin\i386\x86\link.EXE' : return code '0x460' 

What may be the linking problem here also?

Was it helpful?

Solution 3

It's not possible to use cout or printf statements in these kind of WinCE applications as 010110110101 said.

Instead, for displaying text, we shall use DEBUGMSG or RETAILMSG based on the build mode.

DEBUGMSG(TRUE,(TEXT("Hello World")));

RETAILMSG(TRUE,(TEXT("Hello World")));

For example, DEBUGMSG won't work in Release mode. The syntax for these messages is in this link.

OTHER TIPS

The C code that you wrote, will not work in a WinCE app. The entry point for your WinCE app is WinMain, not regular main.

All that iostream stuff is from the STL. From my own experience there are some differences in how the STL is actually implemented on WinCE versus on Windows Desktop. That will be the source of issues now and in the future. Here's an SO article discussing these problems.

Here is how you might do it in WinCE (code not actually tested)

#include "stdafx.h"

using namespace std;
#include <iostream>

int WINAPI WinMain (
      _In_  HINSTANCE hInstance,
      _In_  HINSTANCE hPrevInstance,
      _In_  LPSTR lpCmdLine,
      _In_  int nCmdShow)
{
    cout << "hello world" << endl;
    return 0;
}

A Windows Application and a WinCE application follows different rules and needs different libraries than a console (CRT) app. In your Visual Studio, create a default Win32 project and create a default console app. Then compare the project files between all three in a text compare tool. You'll see many differences. These differences include at least the following:

  • A different entry point -- WinMain, _WinMain, _tWinMain, etc
  • They enable use of the windows.h file and all the related apparatus
  • A different set of default .lib files you must link to

Despite all of this, WinCE apps get fun when you get into the GUI stuff. If I were you, I'd get out of this C++ stuff and get into the C# Compact Framework.

When you want to write a main(argc, argv) style program you must choose console application in the project wizard.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top