在 Windows 中构建 R 包

Building an R package in Windows

我正在尝试使用 Rtools v3.4(最新)在 Windows 中构建 R 包

我已经用 Rcpp 开发了一个包,并且在 Ubuntu 系统中成功构建了它,但是当我尝试在我的 Windows 10 机器上使用命令[=16= 构建它时]

R CMD INSTALL --build --compile-both mypackage

我收到以下错误:

file1.hpp:25:18:   required from here
C:/Rtools/mingw_32/i686-w64-mingw32/include/c++/ext/new_allocator.h:110:30: error: invalid conversion from 'const void*' to 'void*' [-fpermissive]
   { ::operator delete(__p); }

我的 Makefile.win 文件有这样几行:

PKG_CPPFLAGS=-I./dep1/src -I./dep2/cudd -I./dep2/mtr -I./dep2/cplusplus -I./dep2/dddmp -I./dep2/util -I./dep2
CXX_STD=CXX11
PKG_LIBS=-llib1 -lm -fPIC -L./include/windows -llib2

该错误的原因可能是什么?

在@DirkEddelbuettel 评论后编辑:

如果添加 -fpermissive 标志我可以解决该问题,但会出现新错误

R CMD INSTALL --build --compile-both -fpermissive mypackage

file1.hpp:95:71:   required from here
C:/Rtools/mingw_32/i686-w64-mingw32/include/c++/bits/stl_construct.h:75:7: error: invalid static_cast from type 'const std::basic_string<char>*' to type 'void*'
 { ::new(static_cast<void*>(__p)) _T1(std::forward<_Args>(__args)...); }

冲突的 class 具有以下结构:

#ifndef __myKconf__configInfo__
#define __myKconf__configInfo__

#include <iostream>
#include <map>
#include <vector>

class myClass : public parentClass {
    public :
        myClass() {
            ...
        }

    //some public methods

    void addToMenu(const std::string& s) {
        contents.push_back(s);
    }

    private:
        std::vector<const std::string> contents;
        //more private elements
};
#endif

很难添加到常量字符串中...

private:
    std::vector<const std::string> contents;
    //more private elements

成功:

private:
    std::vector<std::string> contents;

你应该是金色的