【发布时间】:2017-09-18 04:53:13
【问题描述】:
我正在尝试在我的 MacBook Pro(13 英寸,2012 年中)上的 Montecarlo 模拟上实现 gsl_rng.h。模拟全部用 C 编写。我的问题是 gcc-6 抱怨它找不到 gsl 库,尽管我认为编译标志很好。
declare.h 的顶部,包含在我正在处理的所有 .c 文件中:
/* __________________ LIBRARIES ___________________*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <gsl/gsl_rng.h>
错误:
fatal error: gsl/gsl_rng.h: No such file or directory
我的 makefile 中包含的编译标志:
INCLUDE = -I/usr/local/Cellar/gsl/2.4/include
LINK = -L/usr/local/Cellar/gsl/2.4/lib -lgsl -lgslcblas
我通过 Homebrew 安装了 gcc-6 和 gsl。
如何让 gcc-6 找到 gsl?我的标志错了吗?
生成文件:
CC = g++-6
CFLAGS = -lm -O3 -ansi -pedantic -Wall -Wextra\
-Wconversion -Wredundant-decls -fmax-errors=7\
-Wunsafe-loop-optimizations -Wmissing-braces\
-Wparentheses
# -Wdouble-promotion
INCLUDE = -I/usr/local/Cellar/gsl/2.4/include
LINK = -L/usr/local/Cellar/gsl/2.4/lib -lgsl -lgslcblas
../bin/bidimensional_MC: random.o functions.o subroutines.o\
main.o
$(CC) -o ../bin/bidimensional_MC random.o functions.o\
subroutines.o main.o $(CFLAGS) $(LINK) $(INLCUDE)
random.o: random.c
$(CC) -c random.c -lm -O3 $(CFLAGS) $(INCLUDE)
functions.o: functions.c
$(CC) -c functions.c $(CFLAGS) $(INCLUDE)
main.o: main.c
$(CC) -c main.c $(CFLAGS) $(INCLUDE)
suboutines.o: subroutines.c
$(CC) -c subroutines.c $(CFLAGS) $(INCLUDE)
clean:
rm *.o
ls /usr/local/Cellar/gsl/2.4/include/gsl/ 的输出为:
/usr/local/Cellar/gsl/2.4/include/gsl/gsl_rng.h
ls /usr/local/Cellar/gsl/2.4/include/ 的输出为:
gsl/
ls /usr/local/Cellar/gsl/2.4/include/gsl/ 的输出太长,无法发布,但所有内容都应有尽有。
额外信息: 我使用 g++-6 而不是 gcc-6,因为我最终要在其中执行模拟的集群要求代码符合 C++。
【问题讨论】:
-
/usr/local/Cellar/gsl/2.4是一个有效的目录吗?包含路径和库路径是否有效? -
ls /usr/local/Cellar/gsl/2.4/include/gsl/gsl_rng.h /usr/local/Cellar/gsl/2.4/include/gsl/ /usr/local/Cellar/gsl/2.4/include/的输出是什么? -
@RetiredNinja 它们是存储所有内容的绝对路径。也许您期望类似:
/usr/local/include但它只包含指向我之前编写的路径的符号链接。 -
您在 makefile 中包含了一些标志;它们在规则中使用吗?执行的命令是什么?如有必要,请使用
make -n查找 - 您需要查看并报告 GCC 的调用。 -
@MagannaDev 好。然后我怀疑你的makefile没有使用编译标志。因此发布你的makefile的MCVE ... /证明
-I实际上是给gcc的。 (就像乔纳森说的)