Brian Sweeney
Brian Sweeney

Reputation: 6815

unable to build C++ project for windows mobile

I'm trying to build a sample project for windows mobile (pre-windows phone 7). I've created a Win32 device project in VS 2008 and i have the windows mobile SDKs installed. 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. Can anyone suggest anything that might help?

Taken from: Auto-launching CF apps with the HKLM\Init Registry Key

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:

According to the WaitForAPIReady documentation i need to include kfuncs.h and according to the IsAPIReady documentation i should use windev.h. When i #include "kfuncs.h" i get no syntax errors, but the linker still complains. When i #include "windev.h" i get file not found.

Any ideas? thanks, brian

Upvotes: 2

Views: 680

Answers (3)

nobody
nobody

Reputation: 20174

Why are you declaring the functions yourself instead of #include'ing kfuncs.h?

Upvotes: 0

Sorcerer86pt
Sorcerer86pt

Reputation: 447

Do an dumpbin /EXPORTS of the dll and see how it is mangled. 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.

Upvotes: 0

Seva Alekseyev
Seva Alekseyev

Reputation: 61388

Don't declare them as 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.

Upvotes: 1

Related Questions