简体   繁体   English

无法为Windows Mobile构建C ++项目

[英]unable to build C++ project for windows mobile

I'm trying to build a sample project for windows mobile (pre-windows phone 7). 我正在尝试为Windows Mobile(Windows Phone 7之前的版本)构建示例项目。 I've created a Win32 device project in VS 2008 and i have the windows mobile SDKs installed. 我已经在VS 2008中创建了Win32设备项目,并且安装了Windows Mobile SDK。 I replace the main function stub with the following sample code, but it fails to build with two linker errors. 我将主函数存根替换为以下示例代码,但由于两个链接器错误而无法构建。 I'm guessing this is some sort of configuration error or build settings error but i don't know where to look. 我猜这是某种配置错误或构建设置错误,但我不知道在哪里看。 I've built very few C++ projects and i'm not familiar with the different options. 我建立的C ++项目很少,我对不同的选项也不熟悉。 Can anyone suggest anything that might help? 有人可以提出任何可能有用的建议吗?

Taken from: Auto-launching CF apps with the HKLM\\Init Registry Key 摘自: 使用HKLM \\ Init注册表项自动启动CF应用程序

extern "C" DWORD WaitForAPIReady(DWORD, DWORD);
extern "C" BOOL IsAPIReady(DWORD hAPI);

int _tmain(int argc, _TCHAR* argv[])
{
    // quick sanity check - HKLM\Init will send in our order number
    if(argc == 0) return 0;

    BOOL success = FALSE;

    // wait for window manager - that should be enough for us
    #if _WIN32_WCE > 0x500
        success = (WaitForAPIReady(SH_WMGR, 5000) == WAIT_OBJECT_0);
    #else
        int i = 0;
        while((! IsAPIReady(SH_WMGR)) && (i++ < 50))
        {
             Sleep(100);
        }

        success = (i < 50);
    #endif

    if(success)
    {
        int launchCode = _ttoi(argv[1]);
        SignalStarted(launchCode);
    }
    else
    {
        RETAILMSG(TRUE, (_T("CFInitGate timed out - SH_WMGR was not ready after 5 seconds\r\n")));
    }

    return 0;
}

And the linker errors i see: 我看到的链接器错误:

  • Error 1 error LNK2019: unresolved external symbol WaitForAPIReady referenced in function wmain LaunchGate.obj LaunchGate 错误1错误LNK2019:函数wmain LaunchGate.obj LaunchGate中引用了未解析的外部符号WaitForAPIReady
  • Error 2 fatal error LNK1120: 1 unresolved externals Windows Mobile 6 Standard SDK LaunchGate 错误2致命错误LNK1120:1个未解决的外部Windows Mobile 6 Standard SDK LaunchGate

According to the WaitForAPIReady documentation i need to include kfuncs.h and according to the IsAPIReady documentation i should use windev.h . 根据WaitForAPIReady文档,我需要包括kfuncs.h ;根据IsAPIReady文档,我应该使用windev.h When i #include "kfuncs.h" i get no syntax errors, but the linker still complains. 当我#include "kfuncs.h"我没有语法错误,但是链接器仍然抱怨。 When i #include "windev.h" i get file not found. 当我#include "windev.h"找不到文件。

Any ideas? 有任何想法吗? thanks, brian 谢谢,布莱恩

Don't declare them as extern "C" . 不要将它们声明为extern "C" Declare thus: 因此声明:

extern WINAPI DWORD WaitForAPIReady(DWORD, DWORD);
extern WINAPI BOOL IsAPIReady(DWORD hAPI);

It's a different calling convention - stdcall vs. cdecl, thus different name mangling rules. 这是不同的调用约定-stdcall vs. cdecl,因此使用了不同的名称处理规则。

Do an dumpbin /EXPORTS of the dll and see how it is mangled. 对dll进行dumpbin / EXPORTS,看看它是如何变形的。 if you see an bunch of odd symbols, it's an c++ created dll and you should declare them as seva answered, else you should declare them as you do. 如果看到一堆奇怪的符号,则说明这是C ++创建的dll,应将其声明为seva回答,否则应按声明的方式进行声明。

为什么要自己声明函数而不是#include'ing kfuncs.h?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM