Published on

Boost.Thread - Windows XP で GetTickCount64 エラー

Authors

会社で装置を操作する DLL を作っています.今日,新機能を追加しユーザにリリースした所,下記のランタイムエラーが発生するという報告を受けました.

エントリポイントが見つかりません
プロシージャエントリポイント GetTickCount64 がダイナミックライブラリ KERNEL32.dll から見つかりませんでした。
Entry Point Not Found
The procedure entry point GetTickCount64 could not be located in the dynamic link library KERNEL32.dll.

調べた所,DLL のターゲットバージョンが Windows Vista 以降となっており,Boost.Thread 内部で GetTickCount64 が使われているのが原因でした.boost/thread/win32/thread_primitives.hpp の中で _WIN32_WINNT のバージョンが Vista(0x0600) 以降だった場合には,GetTickCount64 が呼ばれる用になっています.Vista 以前では GetTickCount64 がないらしく,該当エラーが発生した模様です.

// <boost/thread/win32/thread_primitives.hpp>

#ifndef BOOST_THREAD_WIN32_HAS_GET_TICK_COUNT_64
#if _WIN32_WINNT >= 0x0600
#define BOOST_THREAD_WIN32_HAS_GET_TICK_COUNT_64
#endif
#endif
#ifdef BOOST_THREAD_WIN32_HAS_GET_TICK_COUNT_64
            using ::GetTickCount64;
#else
            inline ticks_type GetTickCount64() { return GetTickCount(); }
#endif

DLL の targetver.h で 下記の部分を修正しました.

#ifndef WINVER
- #define WINVER 0x0600
+ #define WINVER 0x0501
#endif

#ifndef _WIN32_WINNT
- #define _WIN32_WINNT 0x0600
+ #define _WIN32_WINNT 0x0501
#endif