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,
我是Visual Studio 2008(32位)的初学者。我使用的WinCE版本是7.0评估。我创建了一个新项目,
New Project -> Platform Builder-> OS Design
新项目->平台建设者->操作系统设计。
Selected the BSP as,
选择了BSP,
BSP: Generic CEPC:x86
BSP:通用CEPC:x86
When the design template highlighted Consumer Media Device
, I just clicked Finish
.
当设计模板突出显示了消费者媒体设备时,我只是点击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
.
以上选择对我来说是必须的。除此之外,我还创建了一个简单的hello world应用程序,并添加了一个line cout<< hello world >;(因为它们是默认的cpp文件)。我也包括iostream。
I got errors such as,
我有一些错误,比如,
fatal error C1083: Cannot open include file: 'iostream': No such file or directory
致命错误C1083:不能打开包含文件:“iostream”:没有这样的文件或目录。
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
.
如此链接所述,我检查了libcmtd。lib和它在$(VCInstallDir)lib中。它也被包括在|选项|项目和解决方案| vc++目录|显示目录为->库文件。
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,
C程序,
#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?
这里的链接问题是什么?
3 个解决方案
#1
1
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.
你写的C代码不会在WinCE应用程序中工作。WinCE应用程序的入口点是WinMain,而不是普通的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.
所有这些东西都是来自STL。从我自己的经验来看,STL在WinCE和Windows桌面的实际应用上有一些不同。这将是现在和将来问题的根源。下面是一篇讨论这些问题的文章。
Here is how you might do it in WinCE (code not actually tested)
下面是如何在WinCE中实现它(代码没有经过实际测试)
#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:
Windows应用程序和WinCE应用程序遵循不同的规则,需要不同的库,而不是一个控制台(CRT)应用程序。在Visual Studio中,创建一个默认的Win32项目并创建一个默认的控制台应用程序。然后在一个文本比较工具中比较这三个项目文件。你会看到许多的差异。这些差异至少包括以下几点:
- A different entry point -- WinMain, _WinMain, _tWinMain, etc
- 一个不同的入口点——WinMain, _WinMain, _tWinMain,等等。
- They enable use of the windows.h file and all the related apparatus
- 他们允许使用窗户。h文件和所有相关设备。
- A different set of default .lib files you must link to
- 您必须链接到另一组默认的.lib文件。
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.
尽管如此,当你进入GUI的时候,WinCE应用程序会变得很有趣。如果我是你,我会跳出这个c++的东西,进入c#紧凑的框架。
#2
0
When you want to write a main(argc, argv)
style program you must choose console application in the project wizard.
当您想要编写一个主(argc, argv)样式程序时,您必须在项目向导中选择控制台应用程序。
#3
0
It's not possible to use cout
or printf
statements in these kind of WinCE applications as 010110110101
said.
在这种WinCE应用程序中使用cout或printf语句是不可能的,如010110110101。
Instead, for displaying text, we shall use DEBUGMSG
or RETAILMSG
based on the build mode.
相反,对于显示文本,我们将使用基于构建模式的DEBUGMSG或RETAILMSG。
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.
例如,DEBUGMSG不会在发布模式下工作。这些消息的语法在这个链接中。
#1
1
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.
你写的C代码不会在WinCE应用程序中工作。WinCE应用程序的入口点是WinMain,而不是普通的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.
所有这些东西都是来自STL。从我自己的经验来看,STL在WinCE和Windows桌面的实际应用上有一些不同。这将是现在和将来问题的根源。下面是一篇讨论这些问题的文章。
Here is how you might do it in WinCE (code not actually tested)
下面是如何在WinCE中实现它(代码没有经过实际测试)
#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:
Windows应用程序和WinCE应用程序遵循不同的规则,需要不同的库,而不是一个控制台(CRT)应用程序。在Visual Studio中,创建一个默认的Win32项目并创建一个默认的控制台应用程序。然后在一个文本比较工具中比较这三个项目文件。你会看到许多的差异。这些差异至少包括以下几点:
- A different entry point -- WinMain, _WinMain, _tWinMain, etc
- 一个不同的入口点——WinMain, _WinMain, _tWinMain,等等。
- They enable use of the windows.h file and all the related apparatus
- 他们允许使用窗户。h文件和所有相关设备。
- A different set of default .lib files you must link to
- 您必须链接到另一组默认的.lib文件。
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.
尽管如此,当你进入GUI的时候,WinCE应用程序会变得很有趣。如果我是你,我会跳出这个c++的东西,进入c#紧凑的框架。
#2
0
When you want to write a main(argc, argv)
style program you must choose console application in the project wizard.
当您想要编写一个主(argc, argv)样式程序时,您必须在项目向导中选择控制台应用程序。
#3
0
It's not possible to use cout
or printf
statements in these kind of WinCE applications as 010110110101
said.
在这种WinCE应用程序中使用cout或printf语句是不可能的,如010110110101。
Instead, for displaying text, we shall use DEBUGMSG
or RETAILMSG
based on the build mode.
相反,对于显示文本,我们将使用基于构建模式的DEBUGMSG或RETAILMSG。
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.
例如,DEBUGMSG不会在发布模式下工作。这些消息的语法在这个链接中。