错误:' GetSystemTimeAsFileTime'的冲突类型在mingw64上构建cmake + boost项目

时间:2017-11-29 18:50:11

标签: c++ boost cmake mingw mingw-w64

尝试使用Mingw64构建基于CMake和Boost的C ++项目。 我安装了cmake和boost msys2-mingw64软件包。 针对LPFILETIME的有冲突类型(FILETIME vs GetSystemTimeAsFileTime)获取此错误。

$ cmake --build .
[  1%] Building CXX object CMakeFiles/...
In file included from ....cpp:1:
In file included from C:/msys64/mingw64/include\boost/thread.hpp:13:
In file included from C:/msys64/mingw64/include\boost/thread/thread.hpp:12:
In file included from C:/msys64/mingw64/include\boost/thread/thread_only.hpp:15:
In file included from C:/msys64/mingw64/include\boost/thread/win32/thread_data.hpp:10:
In file included from C:/msys64/mingw64/include\boost/thread/thread_time.hpp:10:
In file included from C:/msys64/mingw64/include\boost/date_time/microsec_time_clock.hpp:23:
C:/msys64/mingw64/include\boost/date_time/filetime_functions.hpp:57:46: error: conflicting types for 'GetSystemTimeAsFileTime'
        __declspec(dllimport) void __stdcall GetSystemTimeAsFileTime(FILETIME* lpFileTime);
                                             ^
C:\msys64\mingw64\x86_64-w64-mingw32\include\sysinfoapi.h:38:26: note: previous declaration is here
  WINBASEAPI VOID WINAPI GetSystemTimeAsFileTime (LPFILETIME lpSystemTimeAsFileTime);
                         ^

和许多其他类似的错误。

mingw64包中的错误?缺少定义?

1 个答案:

答案 0 :(得分:0)

原来必须定义BOOST_USE_WINDOWS_H

修复CMake项目:

if(WIN32)
    add_definitions(-DBOOST_USE_WINDOWS_H)
endif()