0

我包括一些头文件:

#include <gsl/gsl_machine.h>
#include <gsl/gsl_rng.h>
#include <gsl/gsl_randist.h>
#include <gsl/gsl_cdf.h>
#include <gsl/gsl_cblas.h>
#include <gsl/gsl_sf_gamma.h>
#include <gsl/gsl_vector.h>
#include <gsl/gsl_matrix.h>
#include <gsl/gsl_blas.h>
#include <gsl/gsl_linalg.h>

#include <R.h>
#include <Rmath.h>
#include <Rembedded.h>
#include <Rdefines.h>
#include <R_ext/Lapack.h>
#include <R_ext/Linpack.h>

我可以使用以下命令链接 blas 和 gsl 库(-lm 用于数学?):

gcc -arch x86_64 myfile.c -o myfile -lgsl -lm -lgslcblas

但我得到错误:

myfile.c:21:15: error: R.h: No such file or directory
myfile.c:22:19: error: Rmath.h: No such file or directory
myfile.c:23:23: error: Rembedded.h: No such file or directory
myfile.c:24:22: error: Rdefines.h: No such file or directory
myfile.c:25:26: error: R_ext/Lapack.h: No such file or directory
myfile.c:26:27: error: R_ext/Linpack.h: No such file or directory

编译 C 代码时如何链接头文件?

4

1 回答 1

0

头文件未链接,仅包含。这些错误就是他们所说的:编译器找不到它们。确保它们位于标准包含目录中。也许你没有make installR 库。如果头文件与其他源文件位于同一目录中,则使用双引号而不是尖括号将它们包括在内:

#include "R.h"

您可以将其他目录添加到带有GCC-I标志的标准包含目录列表中。

于 2013-10-04T13:14:30.723 回答