Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/132.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ c+中的错误+;使用GSL软件包_C++_Gcc_Gsl - Fatal编程技术网

C++ c+中的错误+;使用GSL软件包

C++ c+中的错误+;使用GSL软件包,c++,gcc,gsl,C++,Gcc,Gsl,我刚刚在我的机器上安装了GSL软件包。 我已安装到我的控制器(/u/h) 我编写了Make文件: C = g++ CFLAGS = -c -Wall -O3 LDFLAGS = -L/u/h/lib -lgsl -lgslcblas -lm SOURCES = main.cc params.cc OBJECTS = $(SOURCES:.cc=.o) OBJDIR = obj EXECUTABLE = absimulator all: clean $(SOURCES) $(EXECUTABLE

我刚刚在我的机器上安装了GSL软件包。 我已安装到我的控制器(/u/h) 我编写了Make文件:

C = g++
CFLAGS = -c -Wall -O3
LDFLAGS = -L/u/h/lib -lgsl -lgslcblas -lm
SOURCES = main.cc params.cc
OBJECTS = $(SOURCES:.cc=.o)
OBJDIR = obj
EXECUTABLE = absimulator

all: clean $(SOURCES) $(EXECUTABLE)

.cc.o:
        $(CC) $(CFLAGS) $(OPTION) $< -o $@

finish_compile: $(OBJECTS)
        mkdir $(OBJDIR)
        mv *.o $(OBJDIR)

$(EXECUTABLE): finish_compile
        $(CC) $(LDFLAGS) $(OBJDIR)/*.o -o $@

clean:
        rm -Rf $(OBJDIR) $(EXECUTABLE)

clean_run:
        rm results/*
        rm absimulator absimulator_*
        rm time*
C=g++
CFLAGS=-c-壁面-O3
LDFLAGS=-L/u/h/lib-lgsl-lgslcblas-lm
SOURCES=main.cc params.cc
对象=$(源:.cc=.o)
OBJDIR=obj
可执行文件=模拟程序
全部:清除$(源)$(可执行)
.cc.o:
$(CC)$(CFLAGS)$(选项)$<-o$@
完成编译:$(对象)
mkdir$(OBJDIR)
mv*.o$(OBJDIR)
$(可执行文件):完成编译
$(CC)$(LDFLAGS)$(OBJDIR)/*.o-o$@
清洁:
rm-Rf$(OBJDIR)$(可执行)
清洁运行:
rm结果/*
rm脱落刺激物脱落刺激物_*
rm时间*
我得到了一个错误:

rm -Rf obj absimulator
g++ -c -Wall -O3  main.cc -o main.o
g++ -c -Wall -O3  params.cc -o params.o
mkdir obj
mv *.o obj
g++ -L/u/h/lib -lgsl -lgslcblas -lm  obj/*.o -o absimulator
obj/main.o: In function `ABSimulator<10u>::ABSimulator(Params&, char const*)':
main.cc:(.text._ZN11ABSimulatorILj10EEC2ER6ParamsPKc[_ZN11ABSimulatorILj10EEC5ER6ParamsPKc]+0x127): undefined reference to `gsl_rng_env_setup'
main.cc:(.text._ZN11ABSimulatorILj10EEC2ER6ParamsPKc[_ZN11ABSimulatorILj10EEC5ER6ParamsPKc]+0x12e): undefined reference to `gsl_rng_default'
main.cc:(.text._ZN11ABSimulatorILj10EEC2ER6ParamsPKc[_ZN11ABSimulatorILj10EEC5ER6ParamsPKc]+0x133): undefined reference to `gsl_rng_alloc'
main.cc:(.text._ZN11ABSimulatorILj10EEC2ER6ParamsPKc[_ZN11ABSimulatorILj10EEC5ER6ParamsPKc]+0x142): undefined reference to `gsl_rng_name'
main.cc:(.text._ZN11ABSimulatorILj10EEC2ER6ParamsPKc[_ZN11ABSimulatorILj10EEC5ER6ParamsPKc]+0x1bf): undefined reference to `gsl_rng_default_seed'
main.cc:(.text._ZN11ABSimulatorILj10EEC2ER6ParamsPKc[_ZN11ABSimulatorILj10EEC5ER6ParamsPKc]+0x228): undefined reference to `gsl_rng_get'
main.cc:(.text._ZN11ABSimulatorILj10EEC2ER6ParamsPKc[_ZN11ABSimulatorILj10EEC5ER6ParamsPKc]+0x2c6): undefined reference to `gsl_ran_poisson'
main.cc:(.text._ZN11ABSimulatorILj10EEC2ER6ParamsPKc[_ZN11ABSimulatorILj10EEC5ER6ParamsPKc]+0x2ee): undefined reference to `gsl_ran_poisson'
obj/main.o: In function `ABSimulator<10u>::run(unsigned long long, unsigned long long)':
main.cc:(.text._ZN11ABSimulatorILj10EE3runEyy[_ZN11ABSimulatorILj10EE3runEyy]+0x17f5): undefined reference to `gsl_rng_uniform_int'
main.cc:(.text._ZN11ABSimulatorILj10EE3runEyy[_ZN11ABSimulatorILj10EE3runEyy]+0x184d): undefined reference to `gsl_ran_poisson'
main.cc:(.text._ZN11ABSimulatorILj10EE3runEyy[_ZN11ABSimulatorILj10EE3runEyy]+0x1ed0): undefined reference to `gsl_ran_binomial'
main.cc:(.text._ZN11ABSimulatorILj10EE3runEyy[_ZN11ABSimulatorILj10EE3runEyy]+0x1ef8): undefined reference to `gsl_ran_binomial'
main.cc:(.text._ZN11ABSimulatorILj10EE3runEyy[_ZN11ABSimulatorILj10EE3runEyy]+0x1f28): undefined reference to `gsl_ran_poisson'
main.cc:(.text._ZN11ABSimulatorILj10EE3runEyy[_ZN11ABSimulatorILj10EE3runEyy]+0x2b0e): undefined reference to `gsl_ran_binomial'
main.cc:(.text._ZN11ABSimulatorILj10EE3runEyy[_ZN11ABSimulatorILj10EE3runEyy]+0x2b2e): undefined reference to `gsl_ran_binomial'
main.cc:(.text._ZN11ABSimulatorILj10EE3runEyy[_ZN11ABSimulatorILj10EE3runEyy]+0x2b4e): undefined reference to `gsl_ran_binomial'
main.cc:(.text._ZN11ABSimulatorILj10EE3runEyy[_ZN11ABSimulatorILj10EE3runEyy]+0x2b6e): undefined reference to `gsl_ran_binomial'
main.cc:(.text._ZN11ABSimulatorILj10EE3runEyy[_ZN11ABSimulatorILj10EE3runEyy]+0x2b8e): undefined reference to `gsl_ran_binomial'
obj/main.o:main.cc:(.text._ZN11ABSimulatorILj10EE3runEyy[_ZN11ABSimulatorILj10EE3runEyy]+0x2bae): more undefined references to `gsl_ran_binomial' follow
obj/main.o: In function `main':
main.cc:(.text.startup+0x2bb): undefined reference to `gsl_rng_free'
main.cc:(.text.startup+0x4a0): undefined reference to `gsl_rng_free'
collect2: error: ld returned 1 exit status
make: *** [absimulator] Error 1
rm-Rf obj模拟机
g++-c-Wall-O3 main.cc-o main.o
g++-c-Wall-O3 params.cc-o params.o
mkdir obj
mv*.o obj
g++-L/u/h/lib-lgsl-lgslcblas-lm obj/*.o-o absimulator
obj/main.o:在函数“ABSimulator::ABSimulator(Params&,char const*)”中:
main.cc:(.text._ZN11ABSimulatorILj10EEC2ER6ParamsPKc[_ZN11ABSimulatorILj10EEC5ER6ParamsPKc]+0x127):对“gsl\rng\U环境设置”的未定义引用
main.cc:(.text._ZN11ABSimulatorILj10EEC2ER6ParamsPKc[_ZN11ABSimulatorILj10EEC5ER6ParamsPKc]+0x12e):未定义对“gsl”的引用
main.cc:(.text._ZN11ABSimulatorILj10EEC2ER6ParamsPKc[_ZN11ABSimulatorILj10EEC5ER6ParamsPKc]+0x133):未定义对“gsl”的引用
main.cc:(.text._ZN11ABSimulatorILj10EEC2ER6ParamsPKc[_ZN11ABSimulatorILj10EEC5ER6ParamsPKc]+0x142):未定义对“gsl”的引用
main.cc:(.text._ZN11ABSimulatorILj10EEC2ER6ParamsPKc[_ZN11ABSimulatorILj10EEC5ER6ParamsPKc]+0x1bf):对“gsl”的未定义引用
main.cc:(.text._ZN11ABSimulatorILj10EEC2ER6ParamsPKc[_ZN11ABSimulatorILj10EEC5ER6ParamsPKc]+0x228):对“gsl”的未定义引用
main.cc:(.text._ZN11ABSimulatorILj10EEC2ER6ParamsPKc[_ZN11ABSimulatorILj10EEC5ER6ParamsPKc]+0x2c6):未定义对“gsl”的引用
main.cc:(.text._ZN11ABSimulatorILj10EEC2ER6ParamsPKc[_ZN11ABSimulatorILj10EEC5ER6ParamsPKc]+0x2ee):未定义对“gsl”的引用
obj/main.o:在函数'ABSimulator::run(unsigned long long,unsigned long')中:
main.cc:(.text._zn11absimulatilj10ee3runeyy[_zn11absimulatilj10ee3runeyy]+0x17f5):对“gsl\u rng\u uniform\u int”的未定义引用
main.cc:(.text._zn11Absimulatilj10ee3runeyy[_zn11Absimulatilj10ee3runeyy]+0x184d):对“gsl_ran\u poisson”的未定义引用
main.cc:(.text._ZN11ABSimulatorILj10EE3runEyy[_ZN11ABSimulatorILj10EE3runEyy]+0x1ed0):未定义对“gsl\u ran\u二项式”的引用
main.cc:(.text._ZN11ABSimulatorILj10EE3runEyy[_ZN11ABSimulatorILj10EE3runEyy]+0x1ef8):未定义对“gsl\u ran\u二项式”的引用
main.cc:(.text._zn11absimulatilj10ee3runeyy[_zn11absimulatilj10ee3runeyy]+0x1f28):对“gsl_ran\u poisson”的未定义引用
main.cc:(.text._ZN11ABSimulatorILj10EE3runEyy[_ZN11ABSimulatorILj10EE3runEyy]+0x2b0e):未定义对“gsl_ran_二项式”的引用
main.cc:(.text._ZN11ABSimulatorILj10EE3runEyy[_ZN11ABSimulatorILj10EE3runEyy]+0x2b2e):未定义对“gsl”的引用
main.cc:(.text._ZN11ABSimulatorILj10EE3runEyy[_ZN11ABSimulatorILj10EE3runEyy]+0x2b4e):未定义对“gsl”的引用
main.cc:(.text._ZN11ABSimulatorILj10EE3runEyy[_ZN11ABSimulatorILj10EE3runEyy]+0x2b6e):未定义对“gsl”的引用
main.cc:(.text._ZN11ABSimulatorILj10EE3runEyy[_ZN11ABSimulatorILj10EE3runEyy]+0x2b8e):未定义对“gsl_ran_二项式”的引用
obj/main.o:main.cc:(.text._ZN11ABSimulatorILj10EE3runEyy[_ZN11ABSimulatorILj10EE3runEyy]+0x2bae):下面是对“gsl\u ran\u binomial”的更多未定义引用
obj/main.o:在函数“main”中:
main.cc:(.text.startup+0x2bb):对“gsl\u rng\u free”的未定义引用
main.cc:(.text.startup+0x4a0):对“gsl\u rng\u free”的未定义引用
collect2:错误:ld返回了1个退出状态
make:**[absimulator]错误1
似乎makefile找不到GSL库,我不知道为什么以及如何修复它。。。 你能帮我找出错误吗?
谢谢

链接时,库和对象文件的顺序很重要。将库放在命令行的目标文件之后。感谢您的回答!不幸的是,它不起作用。我在第一个答案中做出了回应。链接的命令行需要是
g++obj/*.o-o absimulator-L/u/h/lib-lgsl-lgslcblas-lm
。请注意
-l
(小写l)选项的位置。如果答案确实是对您的问题的评论或编辑,请不要发布。谢谢。我做到了。现在-我没有得到错误,但是g++没有构建模拟。最后,我没有得到“缺席者”的表扬。我对上一篇文章感到抱歉…链接时,库和对象文件的顺序很重要。将库放在命令行的目标文件之后。感谢您的回答!不幸的是,它不起作用。我在第一个答案中做出了回应。链接的命令行需要是
g++obj/*.o-o absimulator-L/u/h/lib-lgsl-lgslcblas-lm
。请注意
-l
(小写l)选项的位置。如果答案确实是对您的问题的评论或编辑,请不要发布。谢谢。我做到了。现在-我没有得到错误,但是g++没有构建模拟。最后,我没有得到“缺席者”的表扬。我很抱歉之前的帖子。。。