安装 spams 这个软件时报错
In file included from /....../R/R-3.3.0/mybuild/lib64/R/include/R.h:43,
from spams.cpp:1277:
/usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../include/c++/4.4.6/cmath:81: error: template with C linkage
解决方法:
找到提示错误的源代码spams/src/spams.cpp,1277行。这里它引用了安装的R路径下的R.h头文件,R.h又引用了系统gcc安装下的cmath。不知道哪里冲突了。
extern "C" {
#include <R.h>
#include <Rinternals.h>
#include <Rdefines.h>
#include <R_ext/Rdynload.h>
#include <Rembedded.h>
#ifndef WIN32
#include <Rinterface.h>
#endif
#include <R_ext/RS.h>
#include <R_ext/Error.h>
}
#include "spams.h"
试着将extern "C"注释带掉