Table of Contents

编译RTTR


Windows

RTTR在MinGW上编译不通过,所以使用MSVC

在MinGW上编译的时候,有一个警告被指定为了错误,使用-w忽略所有的警告,但是还是可能失败

下载源码,执行cmake

cmake -G"Visual Studio 17 2022" -D"CMAKE_CXX_FLAGS=/w /EHsc" ..

/w是为了取消所有警告,因为有的警告被视为错误
/EHsc使编译器假定声明为 extern “C” 的函数绝不会throw C++异常,这样才能允许关闭警告

在VS中Build这个:INSTALL,编译成功后,需要的文件都在install文件夹里

需要的就还是include,lib,dll那几样

Linux

在Linux上依然编译失败,使用-w忽略警告可以编译通过但是无法通过测试

编译失败的情况

在没有Boost和Doxygen的情况下,使用默认的CMakeList.txt会编译失败,修改如下内容即可编译成功

option(BUILD_RTTR_DYNAMIC "Build the dynamic/shared version of RTTR library" ON)
option(BUILD_UNIT_TESTS "Build the unit tests of RTTR" OFF)
option(BUILD_STATIC "Build RTTR as static library" OFF)
option(BUILD_WITH_STATIC_RUNTIME_LIBS "Link against the static runtime libraries" OFF)
option(BUILD_WITH_RTTI "Enable build with C++ runtime type information for compilation" ON)
option(BUILD_BENCHMARKS "Enable this to build the benchmarks" OFF)
option(BUILD_EXAMPLES "Enable this to build the examples" OFF)
option(BUILD_DOCUMENTATION "Enable this to build the documentation" OFF)
option(BUILD_INSTALLER "Enable this to build the installer" ON)
option(BUILD_PACKAGE "Enable this to build the installer" ON)
option(USE_PCH "Use precompiled header files for compilation" OFF)
option(CUSTOM_DOXYGEN_STYLE "Enable this option to use a custom doxygen style for HTML documentation; Otherwise the default will be used" OFF)
option(BUILD_WEBSITE_DOCU "Enable this option to create the special docu for the website" OFF)
mingw32-make install -j8