{"id":673,"date":"2015-06-16T01:48:51","date_gmt":"2015-06-16T05:48:51","guid":{"rendered":"http:\/\/zhanxw.com\/blog\/?p=673"},"modified":"2015-06-16T01:48:51","modified_gmt":"2015-06-16T05:48:51","slug":"%e4%b8%8d%e8%a6%81%e7%94%a8c11%e7%89%b9%e6%80%a7%e5%bc%80%e5%8f%91r%e5%8c%85","status":"publish","type":"post","link":"https:\/\/zhanxw.com\/blog\/2015\/06\/%e4%b8%8d%e8%a6%81%e7%94%a8c11%e7%89%b9%e6%80%a7%e5%bc%80%e5%8f%91r%e5%8c%85\/","title":{"rendered":"\u4e0d\u8981\u7528C++11\u7279\u6027\u5f00\u53d1R\u5305"},"content":{"rendered":"<p>\u4e0d\u8981\u7528C++11\u7279\u6027\u5f00\u53d1R\u5305<br \/>\nDon&#8217;t use C++11 features to develop R packages<\/p>\n<p>\u8fd9\u662f\u4e2a\u6559\u8bad\u3002\u5728\u6211\u5f00\u53d1<a href=\"http:\/\/cran.r-project.org\/web\/packages\/seqminer\/index.html\" target=\"_blank\">seqminer<\/a>\u7684\u65f6\u5019\u6d6a\u8d39\u592a\u591a\u65f6\u95f4\u4e86\u3002\u5e0c\u671b\u5176\u4ed6\u4eba\u4e0d\u8981\u91cd\u590d\u6211\u7684\u9519\u8bef\u3002<\/p>\n<p>C++11\u6709\u4e0d\u5c11\u6709\u610f\u601d\u7684\u7279\u6027\uff0c\u4f46\u4e3a\u4ec0\u4e48\u4e0d\u8981\u5728\u5f00\u53d1R\u5305\u7684\u65f6\u5019\u4f7f\u7528C++11\u7684\u7279\u6027\u5462\uff08\u8fd9\u91cc\u6307R 3.2\uff09\uff1f\u4e0b\u9762\u6709\u4e00\u4e9b\u539f\u56e0\u3002<\/p>\n<p>1. \u6ca1\u6709\u6e05\u6670\u7684\u6587\u6863<br \/>\nR\u5bf9\u4e8eC++11\u7684\u652f\u6301\u5199\u7684\u5f88\u6a21\u7cca\u3002\u4f60\u9700\u8981\u770b\u4e24\u4e2a\u6587\u6863\uff0c<a href=\"http:\/\/cran.r-project.org\/doc\/manuals\/r-release\/R-exts.html\" target=\"_blank\">Wring R Extensions<\/a>\u548c<a href=\"http:\/\/cran.r-project.org\/doc\/manuals\/r-release\/R-admin.html\" target=\"_blank\">R Installation and Administration<\/a>\u3002<br \/>\n\u7b2c\u4e00\u4e2a\u6587\u6863\u63d0\u5230\u4f60\u9700\u8981CXX_STD\uff0c\u7b2c\u4e8c\u4e2a\u6587\u6863\u63d0\u5230CXX1XFLAGS\u3002\u8fd9\u65f6\u5019\u4f60\u77e5\u9053\u5e94\u8be5\u8bbe\u7f6e\u4e00\u4e9b\u53d8\u91cf\uff0c\u4f46\u600e\u4e48\u8bbe\u7f6e\uff1f\u6ca1\u6709\u6587\u6863\u544a\u8bc9\u4f60\u3002<\/p>\n<p>\u8fd9\u91cc\u6211\u627e\u5230\u4e00\u4e2a\u65b9\u6848\uff0c\u53ef\u4ee5\u51d1\u5408\u7528\u3002\u4f60\u9700\u8981\u6539configure.ac\u6587\u4ef6\u3002\u4e0d\u8fc7\u4f60\u4ecd\u4f1a\u78b0\u5230\u4e0b\u9762\u63d0\u5230\u7684\u7b2c3\u4e2a\u95ee\u9898\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\ndnl https:\/\/github.com\/cran\/dfcomb\/blob\/master\/configure.ac\r\ndnl copy the following lines to configure.ac\r\n\r\nAC_DEFUN(&#x5B;AX_GET_R_CONF_VAR],&#x5B;$1=`&quot;${R_HOME}\/bin\/R&quot; CMD config $1`])\r\nAX_GET_R_CONF_VAR(&#x5B;CC])\r\nAX_GET_R_CONF_VAR(&#x5B;CFLAGS])\r\nAX_GET_R_CONF_VAR(&#x5B;CPPFLAGS])\r\nAX_GET_R_CONF_VAR(&#x5B;CXXCPP])\r\nAX_GET_R_CONF_VAR(&#x5B;CXX1X])\r\nAX_GET_R_CONF_VAR(&#x5B;CXX1XSTD])\r\nAX_GET_R_CONF_VAR(&#x5B;CXX1XFLAGS])\r\nAX_GET_R_CONF_VAR(&#x5B;CXX1XXPICFLAGS])\r\n\r\nCXX=&quot;${CXX1X} ${CXX1XSTD}&quot;\r\nCXXFLAGS=&quot;${CXX1XFLAGS} ${CXX1XPICFLAGS}&quot;\r\nCXXPICFLAGS=&quot;${CXX1XXPICFLAGS}&quot;\r\n<\/pre>\n<p>2. \u8de8\u5e73\u53f0\u652f\u6301\u5f88\u8270\u96be<\/p>\n<p>\u5f53\u4f60\u628a\u5305\u63d0\u4ea4\u5230CRAN\u65f6\uff0c\u5f88\u6709\u53ef\u80fd\u5728Solaris\u7cfb\u7edf\u4e0a\u51fa\u73b0\u7f16\u8bd1\u6216\u8fd0\u884c\u7684\u9519\u8bef\u3002<br \/>\n\u5982\u679c\u4f60\u4f7f\u7528\u4e86C++11\u7684\u529f\u80fd\uff0c\u4f60\u53ef\u80fd\u60f3\u5728\u81ea\u5df1\u5b89\u88c5Solaris\u8bd5\u8bd5\u3002<br \/>\n\u4ece\u6211\u7684\u7ecf\u9a8c\u6765\u770b\uff0cSolaris11 + Solaris Studio 12.4\u73af\u5883\u6bd4\u8f83\u597d\u642d\u5efa\u3002<br \/>\n\u4f46CRAN\u4e0a\u7528\u7684\u662f\u5f88\u8001\u7684Solaris10 + Solaris Studio 12.3\u3002<br \/>\n\u5982\u679c\u4f60\u60f3\u642d\u5efa\u8fd9\u4e2a\u7cfb\u7edf\uff0c\u4f60\u9700\u8981\u4ece\u6e90\u4ee3\u7801\u7f16\u8bd1R\uff0c\u7136\u540e\u4f60\u4f1a\u53d1\u73b0\uff0c\u7f16\u8bd1\u4e0d\u4e86\uff01<br \/>\n\u6211\u53d1\u73b0blas\u5e93\u65e0\u6cd5\u88ab\u94fe\u63a5\u3002\u56e0\u6b64\u4f60\u5728\u63d0\u4ea4R\u5305\u5230CRAN\u65f6\uff0c\u6700\u597d\u660e\u786e\u8bf4\uff0c\u6211\u4e0d\u652f\u6301Solaris\u3002<\/p>\n<p>3. \u652f\u6301Linux\u7cfb\u7edf\u4e5f\u4f1a\u51fa\u95ee\u9898<\/p>\n<p>\u5728Linux\u7cfb\u7edf\u4e0a\uff0c\u4e5f\u8bb8gcc\u7684\u7248\u672c\u5f88\u65b0\uff0c\u53ef\u4ee5\u652f\u6301C++11\uff0c\u4f46\u5982\u679c<strong>\u5b89\u88c5R<\/strong>\u7684\u65f6\u5019\u6ca1\u6709\u8bbe\u7f6eC++11\u9700\u8981\u7684\u4e00\u4e9b\u53d8\u91cf\uff0c\u4f60\u8fd8\u662f\u7528\u4e0d\u4e86\u3002<br \/>\n\u6bd4\u5982Ubuntu\u7cfb\u7edf\u91cc\uff0c R\u662f\u7528apt\u5b89\u88c5\u7684\uff0c\u8fd9\u4e2a\u7248\u672c\u7684R\u662f\u9ed8\u8ba4\u4e0d\u77e5\u9053\u4f60\u6709\u6ca1\u6709\u652f\u6301C++11\u7684\u7f16\u8bd1\u5668\u7684\u3002<br \/>\n\u8fd9\u5c31\u662f\u8bf4\uff0c\u4f60\u5728\u5f00\u53d1\u65f6\u4f7f\u7528\u7684R\uff0cCRAN\u4e0a\u7684R\u90fd\u53ef\u4ee5\u5b89\u88c5\u4f60\u7684\u5305\uff0c\u4f46\u4e0d\u4fdd\u8bc1\u4f60\u7684\u7528\u6237\u80fd\u5b89\u88c5\u3002<\/p>\n<p>\u600e\u4e48\u77e5\u9053\u4f60\u7684R\u662f\u5426\u652f\u6301C++11\u5462\uff1f\u4f60\u53ef\u4ee5\u8fd0\u884c\u201cR CMD config&#8221;:<\/p>\n<pre class=\"brush: plain; highlight: [4]; title: ; notranslate\" title=\"\">\r\n  CXX1X         C++ compiler command for C++11 code\r\n  CXX1XSTD      flag used to enable C++11 support\r\n  CXX1XFLAGS    C++11 compiler flags\r\n  CXX1XXPICFLAGS\r\n                special flags for compiling C++11 code to be turned into\r\n                a shared library\r\n<\/pre>\n<p>\u7136\u540e\u770b\u4e00\u4e0bCXX1X\u7684\u503c\uff0c &#8220;R CMD config CXX1X&#8221;\uff0c\u5982\u679c\u8fd9\u4e2a\u503c\u662f\u7a7a\u7684\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u6ca1\u6cd5\u7f16\u8bd1\u5b89\u88c5\u4f60\u5199\u7684R\u5305\uff08install.packages())\u3002<br \/>\n<em>\u987a\u4fbf\u8bf4\u4e00\u4e0b\uff1a CXX1XXPICFLGS\u662f\u4e00\u4e2a\u7b14\u8bef\uff0c\u6b63\u786e\u7684\u62fc\u5199\u662fCXX1XPICFLAGS \uff08\u4e0d\u662f\u4e24\u4e2aXX\uff09<\/em><\/p>\n<p>\u89e3\u51b3\u65b9\u6cd5\uff1a<br \/>\n\u5148\u5728shell\u4e0b\uff1a<\/p>\n<p>export CXX1X=&#8221;g++ -std=c++11&#8243;<br \/>\nexport SHLIB_CXX1XLD=&#8221;g++ -std=c++11 -shared&#8221;<\/p>\n<p>\u7136\u540eR\u91cc\u9762\u5c31\u80fd\u7528install.packages()\u5b89\u88c5\u4e86\u3002<br \/>\n<em>\u987a\u4fbf\u8bf4\u4e00\u4e0b\uff0cSHLIB_CXX1XLD \u6ca1\u6709\u5199\u5728\u624b\u518c\u91cc\u2026\u2026<br \/>\n<\/em><\/p>\n<p>\u73b0\u5728\u603b\u7ed3\u4e00\u4e0b\uff0c\u5982\u679c\u4f60\u7528\u4e86C++11\u7684\u7279\u6027\u5199R\u5305\uff0c\u4f60\u4f1a\u82b1\u5f88\u591a\u65f6\u95f4\u8bfb\u624b\u518c\u8ba9R\u53bb\u9009\u7528\u5408\u9002\u7684\u7f16\u8bd1\u5668\uff0c\u5f88\u96be\u53bb\u652f\u6301CRAN\u4e0a\u7684\u8001\u65e7\u7684Solaris\uff0c\u4e0d\u80fd\u4fdd\u8bc1\u6700\u7ec8\u7528\u6237\u80fd\u591f\u7f16\u8bd1\u5b89\u88c5\u4f60\u7684R\u5305\u3002<br \/>\n\u6240\u4ee5\uff0c\u6211\u7684\u5efa\u8bae\u7684\u662f\uff0c\u5982\u679c\u60f3\u8ba9\u66f4\u591a\u7684\u4eba\u7528\u4f60\u7684R\u5305\uff0c\u522b\u6298\u817eC++11\u7684\u7279\u6027\u53bb\u9002\u5e94R\uff0c\u8fd8\u662f\u5199\u6700portable\u7684C++\u4ee3\u7801\u5427\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e0d\u8981\u7528C++11\u7279\u6027\u5f00\u53d1R\u5305 Don&#8217;t use C++11 features to develop R packages \u8fd9\u662f\u4e2a\u6559\u8bad\u3002\u5728\u6211\u5f00\u53d1seqminer\u7684\u65f6\u5019\u6d6a\u8d39\u592a\u591a\u65f6\u95f4\u4e86\u3002\u5e0c\u671b\u5176\u4ed6\u4eba\u4e0d\u8981\u91cd\u590d\u6211\u7684\u9519\u8bef\u3002 C++11\u6709\u4e0d\u5c11\u6709\u610f\u601d\u7684\u7279\u6027\uff0c\u4f46\u4e3a\u4ec0\u4e48\u4e0d\u8981\u5728\u5f00\u53d1R\u5305\u7684\u65f6\u5019\u4f7f\u7528C++11\u7684\u7279\u6027\u5462\uff08\u8fd9\u91cc\u6307R 3.2\uff09\uff1f\u4e0b\u9762\u6709\u4e00\u4e9b\u539f\u56e0\u3002 1. \u6ca1\u6709\u6e05\u6670\u7684\u6587\u6863 R\u5bf9\u4e8eC++11\u7684\u652f\u6301\u5199\u7684\u5f88\u6a21\u7cca\u3002\u4f60\u9700\u8981\u770b\u4e24\u4e2a\u6587\u6863\uff0cWring R Extensions\u548cR Installation and Administration\u3002 \u7b2c\u4e00\u4e2a\u6587\u6863\u63d0\u5230\u4f60\u9700\u8981CXX_STD\uff0c\u7b2c\u4e8c\u4e2a\u6587\u6863\u63d0\u5230CXX1XFLAGS\u3002\u8fd9\u65f6\u5019\u4f60\u77e5\u9053\u5e94\u8be5\u8bbe\u7f6e\u4e00\u4e9b\u53d8\u91cf\uff0c\u4f46\u600e\u4e48\u8bbe\u7f6e\uff1f\u6ca1\u6709\u6587\u6863\u544a\u8bc9\u4f60\u3002 \u8fd9\u91cc\u6211\u627e\u5230\u4e00\u4e2a\u65b9\u6848\uff0c\u53ef\u4ee5\u51d1\u5408\u7528\u3002\u4f60\u9700\u8981\u6539configure.ac\u6587\u4ef6\u3002\u4e0d\u8fc7\u4f60\u4ecd\u4f1a\u78b0\u5230\u4e0b\u9762\u63d0\u5230\u7684\u7b2c3\u4e2a\u95ee\u9898\u3002 dnl https:\/\/github.com\/cran\/dfcomb\/blob\/master\/configure.ac dnl copy the following lines to configure.ac AC_DEFUN(&#x5B;AX_GET_R_CONF_VAR],&#x5B;$1=`&quot;${R_HOME}\/bin\/R&quot; CMD config $1`]) AX_GET_R_CONF_VAR(&#x5B;CC]) AX_GET_R_CONF_VAR(&#x5B;CFLAGS]) AX_GET_R_CONF_VAR(&#x5B;CPPFLAGS]) AX_GET_R_CONF_VAR(&#x5B;CXXCPP]) AX_GET_R_CONF_VAR(&#x5B;CXX1X]) AX_GET_R_CONF_VAR(&#x5B;CXX1XSTD]) AX_GET_R_CONF_VAR(&#x5B;CXX1XFLAGS]) AX_GET_R_CONF_VAR(&#x5B;CXX1XXPICFLAGS]) CXX=&quot;${CXX1X} ${CXX1XSTD}&quot; CXXFLAGS=&quot;${CXX1XFLAGS} ${CXX1XPICFLAGS}&quot; CXXPICFLAGS=&quot;${CXX1XXPICFLAGS}&quot; 2. \u8de8\u5e73\u53f0\u652f\u6301\u5f88\u8270\u96be \u5f53\u4f60\u628a\u5305\u63d0\u4ea4\u5230CRAN\u65f6\uff0c\u5f88\u6709\u53ef\u80fd\u5728Solaris\u7cfb\u7edf\u4e0a\u51fa\u73b0\u7f16\u8bd1\u6216\u8fd0\u884c\u7684\u9519\u8bef\u3002 \u5982\u679c\u4f60\u4f7f\u7528\u4e86C++11\u7684\u529f\u80fd\uff0c\u4f60\u53ef\u80fd\u60f3\u5728\u81ea\u5df1\u5b89\u88c5Solaris\u8bd5\u8bd5\u3002 \u4ece\u6211\u7684\u7ecf\u9a8c\u6765\u770b\uff0cSolaris11 + Solaris [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,11],"tags":[138,45],"class_list":["post-673","post","type-post","status-publish","format-standard","hentry","category-code","category-sysadmin","tag-c11","tag-r"],"_links":{"self":[{"href":"https:\/\/zhanxw.com\/blog\/wp-json\/wp\/v2\/posts\/673","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zhanxw.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zhanxw.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zhanxw.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/zhanxw.com\/blog\/wp-json\/wp\/v2\/comments?post=673"}],"version-history":[{"count":0,"href":"https:\/\/zhanxw.com\/blog\/wp-json\/wp\/v2\/posts\/673\/revisions"}],"wp:attachment":[{"href":"https:\/\/zhanxw.com\/blog\/wp-json\/wp\/v2\/media?parent=673"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zhanxw.com\/blog\/wp-json\/wp\/v2\/categories?post=673"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zhanxw.com\/blog\/wp-json\/wp\/v2\/tags?post=673"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}