Context: Years of VBA developing and considerable experience with compiled environments, but almost no C++ experience
Problem: Installed eMbedded C++ ver 4.0 and successsfully created an "Hello Wolrd" program via wizard and ran it on iPAQ H4150. I then made a few minor changes and the code run as expected. Next I want to call and run a program on the iPAQ so I made a function called callEXE which in turn called CeCreateProcess. Just to be sure all was well I tried a build. The code compiles 0 errors and 0 warnings, but generates the following link error
TCard.obj : error LNK2019: unresolved external symbol "int __cdecl CeCreateProcess(unsigned short const *,unsigned short const *,struct _SECURITY_ATTRIBUTES *,struct _SECURITY_ATTRIBUTES *,int,unsigned long,void *,unsigned short *,struct _STARTUPIN
OW *,struct _PROCESS_INFORMATION *)" (?CeCreateProcess@@YAHPBG0PAU_SECURITY_ATTRIBUTES@@1HKPAXPAGPAU_STARTUPINFOW@@PAU_PROCESS_INFORMATION@@@Z) referenced in function "int __cdecl callExe(void)" (?callExe@@YAHXZ
ARMV4Rel/TCard.exe : fatal error LNK1120: 1 unresolved external

I have done a string search on both rapi.h and rapi.lib and found CeCreatePorcess and the complier tells me it checked in rapi.lib as well
Searching C:\Program Files\Windows CE Tools\wce420\POCKET PC 2003\lib\ARMV4\aygshell.lib
Searching C:\Program Files\Windows CE Tools\wce420\POCKET PC 2003\Activesync\Lib\rapi.lib
Finished searching librarie
Finished pass

The relevant code snipits follow

#include <rapi.h
//------------------------

BOOL CeCreateProcess
LPCWSTR , LPCWSTR , PSECURITY_ATTRIBUTES , LPSECURITY_ATTRIBUTES ,
BOOL ,
DWORD ,
LPVOID ,
LPWSTR ,
LPSTARTUPINFO ,
LPPROCESS_INFORMATION
);

BOOL CallExe(void)

//---------------------------
BOOL callExe(

BOOL bRet;
LPCWSTR lpApplicationName
LPCWSTR lpCommandLine;

_PROCESS_INFORMATION pi
_PROCESS_INFORMATION *ppi

ppi = &pi

lpApplicationName = TEXT ("\\Windows\\calendar.exe")
lpCommandLine = TEXT ("")

bRet = CeCreateProcess(lpApplicationName, lpCommandLine, NULL, NULL, FALSE, 0, 0, NULL, NULL, ppi)
return 0



Any help will be much appreciate
Thank

Re: C++ link error LNK2019 by KS

KS
Fri May 07 12:57:03 CDT 2004

I'm guessing you're missing something in the link options. If
CeCreateProcess is defined in rapi.lib, you have to include that lib in
your build.

Go to Project >> Settings >> Link tab. In the Object/Library link modules
add "rapi.lib"

KS



"Sam P" <anonymous@discussions.microsoft.com> wrote in message
news:C8BABE8B-9F2E-47FA-8320-AA0644D31B6E@microsoft.com...
> Context: Years of VBA developing and considerable experience with compiled
environments, but almost no C++ experience.
> Problem: Installed eMbedded C++ ver 4.0 and successsfully created an
"Hello Wolrd" program via wizard and ran it on iPAQ H4150. I then made a few
minor changes and the code run as expected. Next I want to call and run a
program on the iPAQ so I made a function called callEXE which in turn called
CeCreateProcess. Just to be sure all was well I tried a build. The code
compiles 0 errors and 0 warnings, but generates the following link error:
> TCard.obj : error LNK2019: unresolved external symbol "int __cdecl
CeCreateProcess(unsigned short const *,unsigned short const *,struct
_SECURITY_ATTRIBUTES *,struct _SECURITY_ATTRIBUTES *,int,unsigned long,void
*,unsigned short *,struct _STARTUPINF
> OW *,struct _PROCESS_INFORMATION *)"
(?CeCreateProcess@@YAHPBG0PAU_SECURITY_ATTRIBUTES@@1HKPAXPAGPAU_STARTUPINFOW
@@PAU_PROCESS_INFORMATION@@@Z) referenced in function "int __cdecl
callExe(void)" (?callExe@@YAHXZ)
> ARMV4Rel/TCard.exe : fatal error LNK1120: 1 unresolved externals
>
> I have done a string search on both rapi.h and rapi.lib and found
CeCreatePorcess and the complier tells me it checked in rapi.lib as well:
> Searching C:\Program Files\Windows CE Tools\wce420\POCKET PC
2003\lib\ARMV4\aygshell.lib:
> Searching C:\Program Files\Windows CE Tools\wce420\POCKET PC
2003\Activesync\Lib\rapi.lib:
> Finished searching libraries
> Finished pass 1
>
> The relevant code snipits follow:
>
> #include <rapi.h>
> //-------------------------
>
> BOOL CeCreateProcess(
> LPCWSTR , LPCWSTR , PSECURITY_ATTRIBUTES , LPSECURITY_ATTRIBUTES ,
> BOOL ,
> DWORD ,
> LPVOID ,
> LPWSTR ,
> LPSTARTUPINFO ,
> LPPROCESS_INFORMATION
> );
>
> BOOL CallExe(void);
>
> //----------------------------
> BOOL callExe()
> {
> BOOL bRet;
> LPCWSTR lpApplicationName;
> LPCWSTR lpCommandLine;
>
> _PROCESS_INFORMATION pi;
> _PROCESS_INFORMATION *ppi;
>
> ppi = &pi;
>
> lpApplicationName = TEXT ("\\Windows\\calendar.exe");
> lpCommandLine = TEXT ("");
>
>
> bRet = CeCreateProcess(lpApplicationName, lpCommandLine, NULL, NULL,
FALSE, 0, 0, NULL, NULL, ppi);
> return 0;
>
> }
>
> Any help will be much appreciated
> Thanks
>



Re: C++ link error LNK2019 by anonymous

anonymous
Fri May 07 13:21:01 CDT 2004

Thanks KS - I already trie that and no change that's what mystifies me. I think it could be something to do with the way calls and prototyping are handled in C++, but I'm too new to know.

Re: C++ link error LNK2019 by KS

KS
Fri May 07 13:27:55 CDT 2004

I think I might know why ... I missed it the first time ...

Why are you declaring the CeCreateProcess() function in your code ... it
should already be defined in the rapi.h file.

KS

> BOOL CeCreateProcess(
> LPCWSTR , LPCWSTR , PSECURITY_ATTRIBUTES , LPSECURITY_ATTRIBUTES ,
> BOOL ,
> DWORD ,
> LPVOID ,
> LPWSTR ,
> LPSTARTUPINFO ,
> LPPROCESS_INFORMATION
> );

Remove this from your code ...



Re: C++ link error LNK2019 by KS

KS
Fri May 07 13:29:14 CDT 2004

Did you add "C:\Program Files\Windows CE Tools\wce420\POCKET PC
2003\Activesync\Lib\" to your link's library path?

It's in Link >> Path >> Additional Library Path

KS

"Sam P" <anonymous@discussions.microsoft.com> wrote in message
news:E1489211-50F1-45CB-85BC-18BF0143E59A@microsoft.com...
> Thanks KS - I already trie that and no change that's what mystifies me. I
think it could be something to do with the way calls and prototyping are
handled in C++, but I'm too new to know.



Re: C++ link error LNK2019 by anonymous

anonymous
Fri May 07 13:51:02 CDT 2004

I thought so too, but when I comment it out the error moves to the compiler
TCard.cpp(91) : error C2065: 'CeCreateProcess' : undeclared identifier

Re: C++ link error LNK2019 by Chris

Chris
Fri May 07 14:20:52 CDT 2004

CeCreateProcess is a RAPI funtion. It is for use on the desktop, not on a
CE device. If you want to start a process on the device from an app on the
device, just use CreateProcess

--
Chris Tacke, eMVP
Co-Founder and Advisory Board Member
www.OpenNETCF.org
---
Windows CE Product Manager
Applied Data Systems
www.applieddata.net


"Sam P" <anonymous@discussions.microsoft.com> wrote in message
news:3B4AEFCB-BB96-44B3-990D-AE96F6D382CA@microsoft.com...
> I thought so too, but when I comment it out the error moves to the
compiler:
> TCard.cpp(91) : error C2065: 'CeCreateProcess' : undeclared identifier



Re: C++ link error LNK2019 by Trevor

Trevor
Fri May 07 14:31:26 CDT 2004

"Sam P" <anonymous@discussions.microsoft.com> wrote in message
news:C8BABE8B-9F2E-47FA-8320-AA0644D31B6E@microsoft.com...
> Context: Years of VBA developing and considerable experience with compiled
environments, but almost no C++ experience.
> Problem: Installed eMbedded C++ ver 4.0 and successsfully created an
"Hello Wolrd" program via wizard and ran it on iPAQ H4150. I then made a few
minor changes and the code run as expected. Next I want to call and run a
program on the iPAQ so I made a function called callEXE which in turn called
CeCreateProcess. Just to be sure all was well I tried a build. The code
compiles 0 errors and 0 warnings, but generates the following link error:
> TCard.obj : error LNK2019: unresolved external symbol "int __cdecl
CeCreateProcess(unsigned short const *,unsigned short const *,struct
_SECURITY_ATTRIBUTES *,struct _SECURITY_ATTRIBUTES *,int,unsigned long,void
*,unsigned short *,struct _STARTUPINF
> OW *,struct _PROCESS_INFORMATION *)"
(?CeCreateProcess@@YAHPBG0PAU_SECURITY_ATTRIBUTES@@1HKPAXPAGPAU_STARTUPINFOW
@@PAU_PROCESS_INFORMATION@@@Z) referenced in function "int __cdecl
callExe(void)" (?callExe@@YAHXZ)
> ARMV4Rel/TCard.exe : fatal error LNK1120: 1 unresolved externals
>
> I have done a string search on both rapi.h and rapi.lib and found
CeCreatePorcess and the complier tells me it checked in rapi.lib as well:
> Searching C:\Program Files\Windows CE Tools\wce420\POCKET PC
2003\lib\ARMV4\aygshell.lib:
> Searching C:\Program Files\Windows CE Tools\wce420\POCKET PC
2003\Activesync\Lib\rapi.lib:
> Finished searching libraries
> Finished pass 1
>

1) Make sure you are compiling for Pocket PC 2003 and not STANDARDK_SDK420
or anything else.
2) Make sure you have rapi.h included (which it looks like you do). It
should be included in the file that uses the RAPI functions or in stdafx.h
to allow all files to use the RAPI functions.
3) Make sure you have rapi.lib linked in. You have to do this for each
configuration (e.g., Debug, Release -- or you can do them ALL at once if you
know what you're doing). If you added rapi.lib to your linker path and then
changed to another build configuration then you need to apply the changes to
that build configuration too.

> The relevant code snipits follow:
>
> #include <rapi.h>
> //-------------------------
>
> BOOL CeCreateProcess(
> LPCWSTR , LPCWSTR , PSECURITY_ATTRIBUTES , LPSECURITY_ATTRIBUTES ,
> BOOL ,
> DWORD ,
> LPVOID ,
> LPWSTR ,
> LPSTARTUPINFO ,
> LPPROCESS_INFORMATION
> );
>

There is no need to prototype CeCreateProcess. It should be prototyped in
RAPI.H. Simply including this file (#include <ras.h>) will bring in the
prototype for CeCreateProcess.

> BOOL CallExe(void);
>
> //----------------------------
> BOOL callExe()
> {

OK. You do realize that in C/C++ function names are case sensitive?
CallExe is not the same as callExe. C/C++ programmers typically prototype
their functions in .h files and then include the .h file in any .cpp file
that needs to reference the functions.

> BOOL bRet;
> LPCWSTR lpApplicationName;
> LPCWSTR lpCommandLine;
>
> _PROCESS_INFORMATION pi;
> _PROCESS_INFORMATION *ppi;
>
> ppi = &pi;
>
> lpApplicationName = TEXT ("\\Windows\\calendar.exe");
> lpCommandLine = TEXT ("");
>
>
> bRet = CeCreateProcess(lpApplicationName, lpCommandLine, NULL, NULL,
FALSE, 0, 0, NULL, NULL, ppi);
> return 0;
>
> }
>
> Any help will be much appreciated
> Thanks
>

You've got the wrong idea here. You only need one PROCESS_INFORMATION
structure (I don't know where you got the leading underscore from?). Try
something like this:

PROCESS_INFORMATION pi;
...
bRet = CeCreateProcess(lpApplicationName, lpCommandLine, NULL, NULL, FALSE,
0, 0, NULL, NULL, &pi);
// Now pi will be populated by the CeCreateProcess function

This creates a PROCESS_INFORMATION structure on the stack and the
CeCreateProcess function fills in the PROCESS_INFORMATION structure. You
need to read the docs for each function to see if the Windows function fills
it in for you (use the method I have shown) or if the Windows function
returns a pointer to the structure (use the method you have shown).


HTH



RE: C++ link error LNK2019 by anonymous

anonymous
Fri May 07 15:06:03 CDT 2004

Thanks, everyone, for all your help.