在Windows下Mingw + clang vs Boost:不同类型的错误

时间:2016-03-10 15:16:40

标签: c++ windows boost mingw llvm-clang

我准备了一个针对32位Windows的llvm-clang编译器。我使用了3.7.1并应用了this patch。我得到的东西几乎有效,除了我有提升错误。

如果我使用我常用的boost 1.53标头编译我的项目(通常与mingw-gcc一起使用),我遇到麻烦,包括boost/interprocess组件

In file included from [...]/Boost/include-WINDOWS/boost-1_53\boost/interprocess/sync/interprocess_semaphore.hpp:24:
In file included from [...]/Boost/include-WINDOWS/boost-1_53\boost/interprocess/exceptions.hpp:20:
In file included from [...]/Boost/include-WINDOWS/boost-1_53\boost/interprocess/errors.hpp:37:
[...]/Boost/include-WINDOWS/boost-1_53\boost/interprocess/detail/win32_api.hpp:878:48: error: conflicting types for 'VirtualProtect'

如果我然后尝试recompile boost

bootstrap.bat mingw
b2 toolset=clang --with-thread --with-filesystem --with-signals --with-test --with-system --with-regex --with-program_options --with-serialization variant=release link=shared threading=multi

根据各种版本的提升,我收到很多警告,我可以尝试忽略,但也有一些错误:

对于1.56和1.57这些:(不是很多,但我不知道如何摆脱它)

In file included from libs\serialization\src\xml_wiarchive.cpp:35:
.\boost/archive/impl/archive_serializer_map.ipp:41:34: error: redeclaration of 'boost::archive::detail::archive_serializer_map::insert' cannot add 'dllexport' attribute
archive_serializer_map<Archive>::insert(const basic_serializer * bs){
                                 ^
.\boost/archive/detail/archive_serializer_map.hpp:42:17: note: previous declaration is here
    static bool insert(const basic_serializer * bs);
                ^
In file included from libs\serialization\src\xml_wiarchive.cpp:35:
.\boost/archive/impl/archive_serializer_map.ipp:49:34: error: redeclaration of 'boost::archive::detail::archive_serializer_map::erase' cannot add 'dllexport' attribute
archive_serializer_map<Archive>::erase(const basic_serializer * bs){
                                 ^
.\boost/archive/detail/archive_serializer_map.hpp:43:17: note: previous declaration is here
    static void erase(const basic_serializer * bs);
                ^
In file included from libs\serialization\src\xml_wiarchive.cpp:35:
.\boost/archive/impl/archive_serializer_map.ipp:61:34: error: redeclaration of 'boost::archive::detail::archive_serializer_map::find' cannot add 'dllexport' attribute
archive_serializer_map<Archive>::find(
                                 ^
.\boost/archive/detail/archive_serializer_map.hpp:44:37: note: previous declaration is here
    static const basic_serializer * find(
                                    ^

对于1.59和1.60一堆MMX相关的错误,据我所知,这不是我在准备llvm-clang时可以控制的功能:

clang-linux.compile.c++.without-pth bin.v2\libs\thread\build\clang-linux-3.7.1\debug\threading-multi\win32\thread.obj
In file included from libs\thread\src\win32\thread.cpp:17:
In file included from .\boost/thread/thread_only.hpp:15:
In file included from .\boost/thread/win32/thread_data.hpp:11:
In file included from .\boost/thread/win32/thread_primitives.hpp:18:
In file included from .\boost/detail/interlocked.hpp:154:
In file included from C:\Programs\LLVM\bin\..\lib\clang\3.7.1\include\intrin.h:26:
In file included from C:\Programs\MinGW\i686-w64-mingw32\include\Intrin.h:154:
In file included from C:\Programs\LLVM\bin\..\lib\clang\3.7.1\include\mm3dnow.h:27:
C:\Programs\LLVM\bin\..\lib\clang\3.7.1\include\mmintrin.h:28:2: error: "MMX instruction set not enabled"
#error "MMX instruction set not enabled"
 ^
In file included from libs\thread\src\win32\thread.cpp:17:
In file included from .\boost/thread/thread_only.hpp:15:
In file included from .\boost/thread/win32/thread_data.hpp:11:
In file included from .\boost/thread/win32/thread_primitives.hpp:18:
In file included from .\boost/detail/interlocked.hpp:154:
In file included from C:\Programs\LLVM\bin\..\lib\clang\3.7.1\include\intrin.h:26:
In file included from C:\Programs\MinGW\i686-w64-mingw32\include\Intrin.h:154:
C:\Programs\LLVM\bin\..\lib\clang\3.7.1\include\mm3dnow.h:42:41: error: use of undeclared identifier '__v8qi'
  return (__m64)__builtin_ia32_pavgusb((__v8qi)__m1, (__v8qi)__m2);
                                        ^
C:\Programs\LLVM\bin\..\lib\clang\3.7.1\include\mm3dnow.h:42:55: error: use of undeclared identifier '__v8qi'
  return (__m64)__builtin_ia32_pavgusb((__v8qi)__m1, (__v8qi)__m2);
                                                      ^
C:\Programs\LLVM\bin\..\lib\clang\3.7.1\include\mm3dnow.h:47:38: error: cannot convert '__m64' to '__v2sf' (vector of 2 'float' values) without a conversion operator
  return (__m64)__builtin_ia32_pf2id((__v2sf)__m);
                                     ^~~~~~~~~~~
C:\Programs\LLVM\bin\..\lib\clang\3.7.1\include\mm3dnow.h:52:38: error: cannot convert '__m64' to '__v2sf' (vector of 2 'float' values) without a conversion operator
  return (__m64)__builtin_ia32_pfacc((__v2sf)__m1, (__v2sf)__m2);
                                     ^~~~~~~~~~~~
C:\Programs\LLVM\bin\..\lib\clang\3.7.1\include\mm3dnow.h:52:52: error: cannot convert '__m64' to '__v2sf' (vector of 2 'float' values) without a conversion operator
  return (__m64)__builtin_ia32_pfacc((__v2sf)__m1, (__v2sf)__m2);
                                                   ^~~~~~~~~~~~

在MinGW设置中,有没有办法让任何版本的boost能够在Windows下使用clang 32bit?

我也尝试过llvm 3.8.0,但我无法准备它,因为我的MinGW工具链不支持C ++ 11的某些部分(以及我尝试过的其他版本,请参阅here)。

1 个答案:

答案 0 :(得分:-1)

至于boost.thread: 添加-msse(或其他)(解决MMX指令集未启用错误)后,只需将-DBOOST_USE_WINDOWS_H添加到cxxflags,即可解决Windows头文件和boost.date_time中许多系统函数的不同声明。

例如: cxxflags =&#34; -msse -DBOOST_USE_WINDOWS_H&#34;