gfortran未定义的引用

时间:2012-10-09 11:23:34

标签: c++ fortran g++ linker-errors gfortran

我正在尝试编译一个依赖于很多东西的程序。 我使用和修改提供的makefile来代表我的计算机设置,但是在编译的最后一步中我一直得到很多未定义的引用。

导致问题的命令行是:

gfortran -o ../cosmomc ParamNames.o Matrix_utils.o  settings.o IO.o cmbtypes.o Planck_like.o cmbdata.o WeakLen.o &
bbn.o lrggettheory.o mpk.o bao.o supernovae.o HST.o SDSSLy-a-v3.o CMB_Cls_simple.o paramdef.o propose.o params_CMB.o &
calclike.o EstCovmat.o PowellConstrainedMinimize.o minimize.o postprocess.o MCMC.o driver.o /home/darkside/tesis/CosmoMc &
/likelihood_v4p1/read_archive_map.o /home/darkside/tesis/CosmoMc/likelihood_v4p1/read_fits.o /home/darkside/tesis/CosmoMc/likelihood_v4p1/healpix_types.o /home/darkside/tesis &
/CosmoMc/likelihood_v4p1/WMAP_7yr_options.o /home/darkside/tesis/CosmoMc/likelihood_v4p1/WMAP_7yr_util.o /home/darkside/tesis &
/CosmoMc/likelihood_v4p1/WMAP_7yr_tt_pixlike.o /home/darkside/tesis/CosmoMc/likelihood_v4p1/WMAP_7yr_teeebb_pixlike.o /home/darkside/tesis/CosmoMc &
/likelihood_v4p1/WMAP_7yr_likelihood.o /home/darkside/tesis /CosmoMc/likelihood_v4p1/WMAP_7yr_gibbs.o /home/darkside/tesis &
/CosmoMc/likelihood_v4p1/WMAP_7yr_tt_beam_ptsrc_chisq.o /home/darkside/tesis/CosmoMc/likelihood_v4p1/br_mod_dist.o &

-L../camb -lcamb_cosmorec -lblas -llapack -L/usr/lib/gcc & 
/i686-linux-gnu/4.4/ -lstdc++ -L../CosmoRec -lCosmoRec &
-L/usr/lib -lgsl -lgslcblas  -L/usr/lib/i386-linux/gnu/lib &
-L/home/darkside/tesis/CosmoMc/likelihood_v4p1 -lcfitsio &
-DMATRIX_SINGLE -O3 -fopenmp -ffree-form -x f95-cpp-input  &
-ffast-math -march=native -funroll-loops -DCOSMOREC -I../camb &
-I/usr/lib/i386-linux/gnu/include -I/home/darkside/tesis/CosmoMc/likelihood_v4p1

还有一些错误:

../CosmoRec/libCosmoRec.a(CosmoRec.o): In function `__tcf_0':
 CosmoRec.cpp:(.text+0xb): undefined reference to `std::basic_string<char, std::char_traits<char>,  
 std::allocator<char> >::~basic_string()'
 CosmoRec.cpp:(.text+0x17): undefined reference to `std::basic_string<char, std::char_traits<char>,
 std::allocator<char> >::~basic_string()'
 ../CosmoRec/libCosmoRec.a(CosmoRec.o): In function `__tcf_1':
 CosmoRec.cpp:(.text+0x47): undefined reference to `std::basic_string<char, std::char_traits<char>, 
 std::allocator<char> >::~basic_string()'
 ../CosmoRec/libCosmoRec.a(CosmoRec.o): In function `std::_Vector_base<double, std::allocator<double> 
  >::_M_deallocate(double*, unsigned int) [clone .isra.76]':

所有这些都在用g ++编译的包中,所以我猜问题可能是lstdc ++标志。我试图添加库的完整路径和其他选项,但它不起作用。

任何帮助都会得到真正的帮助。

此致 利亚

1 个答案:

答案 0 :(得分:2)

您是否尝试将-lstdc++放在链接命令的 end 上?它需要来自之后任何依赖它的对象和库。