【发布时间】:2023-03-06 17:56:01
【问题描述】:
我正在编写一个包含两个库 RcppArmadillo 和 trng4 的 Rcpp 代码。但是,当我包含两个头文件(RcppArmadillo.h 和 trng/gamma_dist.hpp)时,会出现编译错误。
trng/special_functions.hpp:47:39: error: declaration of ‘float lgammaf(float) throw ()’ has a different exception specifier
extern "C" float lgammaf(float) throw();
include-fixed/math.h:476:14: error: from previous declaration ‘float lgammaf(float)’
extern float lgammaf(float);
完整的编译选项是
-fopenmp -lgomp -DUSE_R -DNDEBUG -DDISABLE_SINGLE -DNTHROW -DDISABLE_FIO -I/usr/local/include -I"/Users/avi/Library/R/3.0/library/Rcpp/include" -I"/Users/avi/Library/R/3.0/library/RcppArmadillo/include" -fPIC -pipe -std=c++0x -Wall -pedantic -c
似乎在两个头文件中都声明了 lgammaf。我尝试将 -E 与 g++ 选项一起使用,但它给出了 ld 警告“.o,文件是为不受支持的文件格式构建的”,并在加载 R 后尝试在 .Call 中不可用时给出错误函数。我做错了什么?
也许我正在使用 trng4 包开发一个线程 gibbs 采样器(在 openmp 中),从 gamma 分布中采样。我目前正在运行这个 MacOS。但最终它会在linux服务器上运行。
【问题讨论】:
标签: c++ gcc compilation openmp rcpp