Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

unresolved linker errors in eVC (PocketPC)

126 views
Skip to first unread message

Allan Bruce

unread,
Aug 14, 2005, 5:55:44 PM8/14/05
to
I am porting one of my applications to PocketPC and have run into a problem.
I use time() to get the current time and also localtime() to get some extra
information. Everything compiles fine but I get a linker error:

WinClient.obj : error LNK2001: unresolved external symbol time
ChatWindow.obj : error LNK2019: unresolved external symbol localtime
referenced in function "public: static void __cdecl
ChatWindow::FormatDate(unsigned short *)" (?FormatDate@ChatWindow@@SAXPAG@Z)
MIPSII_FPDbg/PPCWinClient.exe : fatal error LNK1120: 2 unresolved externals

Does anybody know what lib file I need to include to get this working?
Thanks.
Allan


Jeff Henkels

unread,
Aug 15, 2005, 8:43:46 AM8/15/05
to
"Allan Bruce" <a...@abc.net> wrote in message
news:nuudnY62e_t...@pipex.net...

As far as I know, time/localtime aren't supported in the CE run-time
library -- use the Windows APIs GetSystemTime/GetLocalTime instead. Also,
you might also want to look at GetDateFormat/GetTimeFormat; they do string
formatting based on locale & user control panel settings.


Keks Keksov

unread,
Aug 17, 2005, 11:16:18 AM8/17/05
to
There are two options in solving your problems:

1. If you have a lot of unsupported by WCE functions then use portlib
which is a part of http://www.symbolictools.de/public/pocketconsole/

Note: For creating WCE console application u have to link against
portlib.lib
rename main to wmain and alter entry-point symbol in project's
settings:
Link::Output::mainWCRTStartup

2. Use following functions if u need 'time' and 'localtime' only:

This code is based on SQLite port to WinCE
(http://sqlite-wince.sourceforge.net/)

/*********************************************
* getSecondsSince1970
*********************************************/
time_t getSecondsSince1970()
{

time_t seconds; // C run-time time (defined in <time.h>)

#if defined(_WIN32_WCE) && !defined(_ATL_DLL) && defined(_AFXDLL) //
WinCE with MFC support
seconds = WCE_FCTN(time) (NULL) ;

#elif defined(_WIN32_WCE) // thank you MS for not including 'time'
functions into WCE :-/
FILETIME uf;
SYSTEMTIME st;

GetSystemTime(&st);
SystemTimeToFileTime(&st, &uf);

ULONGLONG i64 = ( (ULONGLONG)uf.dwHighDateTime << 32 ) +
(ULONGLONG)uf.dwLowDateTime; // nanoseconds since 1601
osBinaryTime = (time_t)(( i64 - 116444736000000000 ) / 10000000);

#else // for the rest of the normal world with UNIX 'time' implemented
time(&seconds);
#endif

return(seconds);
}

/*
** Implementation of the localtime function for systems not having it.
** Convert time_t to local time in tm struct format.
*/
struct tm * sqlitewce_localtime( const time_t *timer )
{
static struct tm s_tm;
FILETIME uf, lf;
SYSTEMTIME ls;
// Convert time_t to FILETIME
unsigned __int64 i64 = Int32x32To64(timer, 10000000) +
116444736000000000;
uf.dwLowDateTime = (DWORD) i64;
uf.dwHighDateTime = (DWORD) (i64 >> 32);
// Convert UTC(GMT) FILETIME to local FILETIME
FileTimeToLocalFileTime( &uf, &lf );
// Convert FILETIME to SYSTEMTIME
FileTimeToSystemTime( &lf, &ls );
// Convert SYSTEMTIME to tm
s_tm.tm_sec = ls.wSecond;
s_tm.tm_min = ls.wMinute;
s_tm.tm_hour = ls.wHour;
s_tm.tm_mday = ls.wDay;
s_tm.tm_mon = ls.wMonth -1;
s_tm.tm_year = ls.wYear - 1900;
s_tm.tm_wday = ls.wDayOfWeek;
// Return pointer to static data
return &s_tm;
}

Regards,
Dim Zegebart aka Keks Keksov

0 new messages