gfortran undefined references

和自甴很熟 提交于 2019-12-24 14:50:27

问题


I'm trying to compile a program that depends on a lot of things. I use and modify the makefile provided to stand for my computer settings, but I keep getting a lot of undefined references in the last step of compilation.

The command line that causes the troubles is:

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

And some errors are:

../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]':

All of them are in the package compiled in g++, so I guess the problem can be the lstdc++ flag. I tried to add the complete path to the library and other options, but it doesn't work.

Any help would be really aprecciated.

Regards, Illa


回答1:


Have you tried putting -lstdc++ at th end of the link command? It needs to come after any objects and libraries that depend on it.



来源:https://stackoverflow.com/questions/12798981/gfortran-undefined-references

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!