将 R.h Reembedded.h 与 C 代码链接 [英] Linking R.h Rembedded.h with C code

查看:43
本文介绍了将 R.h Reembedded.h 与 C 代码链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我包含了一些头文件:

#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 用于数学?):

I am able to link the blas and gsl libraries using the following command (the -lm is for math?):

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 代码时如何链接头文件?

How do I link the header files when compiling my C code?

推荐答案

头文件不链接,只包含.错误的意思就是他们所说的:编译器找不到它们.确保它们在标准包含目录中.也许您没有make install R 库.如果头文件与其他源文件位于同一目录中,则将它们用双引号而不是尖括号括起来:

Header files aren't linked, only included. The errors mean just what they say: the compiler can't find them. Make sure they are in the standard include directory. Maybe you didn't make install the R library. If the header files are in the same directory as your other source files include them with double-quotes instead of angle brackets:

#include "R.h"

您可以使用 -I 标志 到 GCC.

You can add other directories to the list of standard include directories with the -I flag to GCC.

这篇关于将 R.h Reembedded.h 与 C 代码链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆