尝试使用Mingw64构建基于CMake和Boost的C++项目。
我安装了cmake并增强了msys2-mingw64软件包。
获得有关LPFILETIME
的类型冲突(FILETIME
与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软件包中的错误?缺少定义?
最佳答案
事实证明,必须定义BOOST_USE_WINDOWS_H
。
修复CMake项目:
if(WIN32)
add_definitions(-DBOOST_USE_WINDOWS_H)
endif()