我有一个我无法理解的编译错误,我认为它抱怨其中一个库中的函数。如果我在Windows或Redhat上编译,只在我的Ubuntu 12.04上,我不会收到此错误。 请帮我找到这个问题的根源,我在网上看过其他帖子但没有解决方案。
这是编译器输出:
mpif90 -w -ffree-line-length-256 -c blah -I/usr/local/dislin/ifc/ -lm
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 0 has invalid symbol index 10
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 1 seconds)
1 errors, 0 warnings (0 minutes, 1 seconds)
代码本身很大所以我不能发布它,但无论如何,似乎链接阶段是问题,我认为它是我的系统,而不是代码。
我使用的是MPICH2 mpif90 1.4.1包装器,带有gfortran 4.6.3
编辑:这是我发送到命令行的内容:
-------------- Build: Debug in K2 (compiler: mpif90 from GNU Fortran Compiler)---------------
mpif90 -Jobj/Debug/ -w -ffree-line-length-256 -c /home/mark/Dropbox/Codes/K2/K2common.F90 -o obj/Debug/Dropbox/Codes/K2/K2common.o
mpif90 -Jobj/Debug/ -w -ffree-line-length-256 -c /home/mark/Dropbox/Codes/K2/K2matrix.F90 -o obj/Debug/Dropbox/Codes/K2/K2matrix.o
mpif90 -Jobj/Debug/ -w -ffree-line-length-256 -c /home/mark/Dropbox/Codes/K2/K2common_parallel.F90 -o obj/Debug/Dropbox/Codes/K2/K2common_parallel.o
mpif90 -Jobj/Debug/ -w -ffree-line-length-256 -c /home/mark/Dropbox/Codes/K2/K2eispack.F90 -o obj/Debug/Dropbox/Codes/K2/K2eispack.o
mpif90 -Jobj/Debug/ -w -ffree-line-length-256 -c /home/mark/Dropbox/Codes/K2/K2advectxi.F90 -o obj/Debug/Dropbox/Codes/K2/K2advectxi.o
mpif90 -Jobj/Debug/ -w -ffree-line-length-256 -c /home/mark/Dropbox/Codes/K2/K2collsee.F90 -o obj/Debug/Dropbox/Codes/K2/K2collsee.o
mpif90 -Jobj/Debug/ -w -ffree-line-length-256 -c /home/mark/Dropbox/Codes/K2/K2convertf.F90 -o obj/Debug/Dropbox/Codes/K2/K2convertf.o
mpif90 -Jobj/Debug/ -w -ffree-line-length-256 -c /home/mark/Dropbox/Codes/K2/K2advectyr.F90 -o obj/Debug/Dropbox/Codes/K2/K2advectyr.o
mpif90 -Jobj/Debug/ -w -ffree-line-length-256 -c /home/mark/Dropbox/Codes/K2/K2advectpi.F90 -o obj/Debug/Dropbox/Codes/K2/K2advectpi.o
mpif90 -Jobj/Debug/ -w -ffree-line-length-256 -c /home/mark/Dropbox/Codes/K2/K2timestep.F90 -o obj/Debug/Dropbox/Codes/K2/K2timestep.o
mpif90 -Jobj/Debug/ -w -ffree-line-length-256 -c /home/mark/Dropbox/Codes/K2/K2hydro.F90 -o obj/Debug/Dropbox/Codes/K2/K2hydro.o
mpif90 -Jobj/Debug/ -w -ffree-line-length-256 -c /home/mark/Dropbox/Codes/K2/K2tests.F90 -o obj/Debug/Dropbox/Codes/K2/K2tests.o
mpif90 -Jobj/Debug/ -w -ffree-line-length-256 -c /home/mark/Dropbox/Codes/K2/K2maxwell.F90 -o obj/Debug/Dropbox/Codes/K2/K2maxwell.o
mpif90 -Jobj/Debug/ -w -ffree-line-length-256 -c /home/mark/Dropbox/Codes/K2/K2parameters.F90 -o obj/Debug/Dropbox/Codes/K2/K2parameters.o
mpif90 -Jobj/Debug/ -w -ffree-line-length-256 -c /home/mark/Dropbox/Codes/K2/K2rotate.F90 -o obj/Debug/Dropbox/Codes/K2/K2rotate.o
mpif90 -Jobj/Debug/ -w -ffree-line-length-256 -c /home/mark/Dropbox/Codes/K2/K2advectp_VL.F90 -o obj/Debug/Dropbox/Codes/K2/K2advectp_VL.o
mpif90 -Jobj/Debug/ -w -ffree-line-length-256 -c /home/mark/Dropbox/Codes/K2/K2correctE.F90 -o obj/Debug/Dropbox/Codes/K2/K2correctE.o
mpif90 -Jobj/Debug/ -w -ffree-line-length-256 -c /home/mark/Dropbox/Codes/K2/K2advectp.F90 -o obj/Debug/Dropbox/Codes/K2/K2advectp.o
mpif90 -Jobj/Debug/ -w -ffree-line-length-256 -c /home/mark/Dropbox/Codes/K2/K2initialise.F90 -o obj/Debug/Dropbox/Codes/K2/K2initialise.o
mpif90 -Jobj/Debug/ -w -ffree-line-length-256 -c /home/mark/Dropbox/Codes/K2/K2collsie.F90 -o obj/Debug/Dropbox/Codes/K2/K2collsie.o
mpif90 -Jobj/Debug/ -w -ffree-line-length-256 -c /home/mark/Dropbox/Codes/K2/K2transport.F90 -o obj/Debug/Dropbox/Codes/K2/K2transport.o
mpif90 -Jobj/Debug/ -w -ffree-line-length-256 -c /home/mark/Dropbox/Codes/K2/K2advectyr4.F90 -o obj/Debug/Dropbox/Codes/K2/K2advectyr4.o
mpif90 -Jobj/Debug/ -w -ffree-line-length-256 -c /home/mark/Dropbox/Codes/K2/K2advectxp.F90 -o obj/Debug/Dropbox/Codes/K2/K2advectxp.o
mpif90 -Jobj/Debug/ -w -ffree-line-length-256 -c /home/mark/Dropbox/Codes/K2/K2fluxes.F90 -o obj/Debug/Dropbox/Codes/K2/K2fluxes.o
mpif90 -Jobj/Debug/ -w -ffree-line-length-256 -c /home/mark/Dropbox/Codes/K2/K2calcGHi.F90 -o obj/Debug/Dropbox/Codes/K2/K2calcGHi.o
mpif90 -Jobj/Debug/ -w -ffree-line-length-256 -c /home/mark/Dropbox/Codes/K2/K2output.F90 -o obj/Debug/Dropbox/Codes/K2/K2output.o
mpif90 -Jobj/Debug/ -w -ffree-line-length-256 -c /home/mark/Dropbox/Codes/K2/K2maxwell2.F90 -o obj/Debug/Dropbox/Codes/K2/K2maxwell2.o
mpif90 -Jobj/Debug/ -w -ffree-line-length-256 -c /home/mark/Dropbox/Codes/K2/K2advecty.F90 -o obj/Debug/Dropbox/Codes/K2/K2advecty.o
mpif90 -Jobj/Debug/ -w -ffree-line-length-256 -c /home/mark/Dropbox/Codes/K2/K2gridi.F90 -o obj/Debug/Dropbox/Codes/K2/K2gridi.o
mpif90 -Jobj/Debug/ -w -ffree-line-length-256 -c /home/mark/Dropbox/Codes/K2/K2extras.F90 -o obj/Debug/Dropbox/Codes/K2/K2extras.o
mpif90 -Jobj/Debug/ -w -ffree-line-length-256 -c /home/mark/Dropbox/Codes/K2/K2magnetic.F90 -o obj/Debug/Dropbox/Codes/K2/K2magnetic.o
mpif90 -Jobj/Debug/ -w -ffree-line-length-256 -c /home/mark/Dropbox/Codes/K2/K2ohms.F90 -o obj/Debug/Dropbox/Codes/K2/K2ohms.o
mpif90 -Jobj/Debug/ -w -ffree-line-length-256 -c /home/mark/Dropbox/Codes/K2/K2collsee_ani.F90 -o obj/Debug/Dropbox/Codes/K2/K2collsee_ani.o
mpif90 -Jobj/Debug/ -w -ffree-line-length-256 -c /home/mark/Dropbox/Codes/K2/K2advectp_cubic.F90 -o obj/Debug/Dropbox/Codes/K2/K2advectp_cubic.o
mpif90 -Jobj/Debug/ -w -ffree-line-length-256 -c /home/mark/Dropbox/Codes/K2/K2advectp_chang.F90 -o obj/Debug/Dropbox/Codes/K2/K2advectp_chang.o
mpif90 -Jobj/Debug/ -w -ffree-line-length-256 -c /home/mark/Dropbox/Codes/K2/K2evolveEB.F90 -o obj/Debug/Dropbox/Codes/K2/K2evolveEB.o
mpif90 -Jobj/Debug/ -w -ffree-line-length-256 -c /home/mark/Dropbox/Codes/K2/K2advectx_ppm.F90 -o obj/Debug/Dropbox/Codes/K2/K2advectx_ppm.o
mpif90 -Jobj/Debug/ -w -ffree-line-length-256 -c /home/mark/Dropbox/Codes/K2/K2smooth.F90 -o obj/Debug/Dropbox/Codes/K2/K2smooth.o
mpif90 -Jobj/Debug/ -w -ffree-line-length-256 -c /home/mark/Dropbox/Codes/K2/K2hybrid.F90 -o obj/Debug/Dropbox/Codes/K2/K2hybrid.o
mpif90 -Jobj/Debug/ -w -ffree-line-length-256 -c /home/mark/Dropbox/Codes/K2/K2grid.F90 -o obj/Debug/Dropbox/Codes/K2/K2grid.o
mpif90 -Jobj/Debug/ -w -ffree-line-length-256 -c /home/mark/Dropbox/Codes/K2/K2advectyr2.F90 -o obj/Debug/Dropbox/Codes/K2/K2advectyr2.o
mpif90 -Jobj/Debug/ -w -ffree-line-length-256 -c /home/mark/Dropbox/Codes/K2/K2collsii.F90 -o obj/Debug/Dropbox/Codes/K2/K2collsii.o
mpif90 -Jobj/Debug/ -w -ffree-line-length-256 -c /home/mark/Dropbox/Codes/K2/K2unused.F90 -o obj/Debug/Dropbox/Codes/K2/K2unused.o
mpif90 -Jobj/Debug/ -w -ffree-line-length-256 -c /home/mark/Dropbox/Codes/K2/K2momentsi.F90 -o obj/Debug/Dropbox/Codes/K2/K2momentsi.o
mpif90 -Jobj/Debug/ -w -ffree-line-length-256 -c /home/mark/Dropbox/Codes/K2/K2colls_ee_gyor.F90 -o obj/Debug/Dropbox/Codes/K2/K2colls_ee_gyor.o
mpif90 -Jobj/Debug/ -w -ffree-line-length-256 -c /home/mark/Dropbox/Codes/K2/K2single.F90 -o obj/Debug/Dropbox/Codes/K2/K2single.o
mpif90 -Jobj/Debug/ -w -ffree-line-length-256 -c /home/mark/Dropbox/Codes/K2/K2initial_calcs.F90 -o obj/Debug/Dropbox/Codes/K2/K2initial_calcs.o
mpif90 -Jobj/Debug/ -w -ffree-line-length-256 -c /home/mark/Dropbox/Codes/K2/K2calcGH.F90 -o obj/Debug/Dropbox/Codes/K2/K2calcGH.o
mpif90 -Jobj/Debug/ -w -ffree-line-length-256 -c /home/mark/Dropbox/Codes/K2/K2moments.F90 -o obj/Debug/Dropbox/Codes/K2/K2moments.o
mpif90 -Jobj/Debug/ -w -ffree-line-length-256 -c /home/mark/Dropbox/Codes/K2/K2advecty_rot.F90 -o obj/Debug/Dropbox/Codes/K2/K2advecty_rot.o
mpif90 -Jobj/Debug/ -w -ffree-line-length-256 -c /home/mark/Dropbox/Codes/K2/K2advectx.F90 -o obj/Debug/Dropbox/Codes/K2/K2advectx.o
mpif90 -o bin/Debug/K2 obj/Debug/Dropbox/Codes/K2/K2common.o obj/Debug/Dropbox/Codes/K2/K2matrix.o obj/Debug/Dropbox/Codes/K2/K2common_parallel.o
obj/Debug/Dropbox/Codes/K2/K2eispack.o obj/Debug/Dropbox/Codes/K2/K2advectxi.o
obj/Debug/Dropbox/Codes/K2/K2collsee.o obj/Debug/Dropbox/Codes/K2/K2convertf.o
obj/Debug/Dropbox/Codes/K2/K2advectyr.o obj/Debug/Dropbox/Codes/K2/K2advectpi.o
obj/Debug/Dropbox/Codes/K2/K2timestep.o obj/Debug/Dropbox/Codes/K2/K2hydro.o
obj/Debug/Dropbox/Codes/K2/K2tests.o obj/Debug/Dropbox/Codes/K2/K2maxwell.o
obj/Debug/Dropbox/Codes/K2/K2parameters.o obj/Debug/Dropbox/Codes/K2/K2rotate.o
obj/Debug/Dropbox/Codes/K2/K2advectp_VL.o obj/Debug/Dropbox/Codes/K2/K2correctE.o
obj/Debug/Dropbox/Codes/K2/K2advectp.o obj/Debug/Dropbox/Codes/K2/K2initialise.o
obj/Debug/Dropbox/Codes/K2/K2collsie.o obj/Debug/Dropbox/Codes/K2/K2transport.o
obj/Debug/Dropbox/Codes/K2/K2advectyr4.o obj/Debug/Dropbox/Codes/K2/K2advectxp.o
obj/Debug/Dropbox/Codes/K2/K2fluxes.o obj/Debug/Dropbox/Codes/K2/K2calcGHi.o
obj/Debug/Dropbox/Codes/K2/K2output.o obj/Debug/Dropbox/Codes/K2/K2maxwell2.o
obj/Debug/Dropbox/Codes/K2/K2advecty.o obj/Debug/Dropbox/Codes/K2/K2gridi.o
obj/Debug/Dropbox/Codes/K2/K2extras.o obj/Debug/Dropbox/Codes/K2/K2magnetic.o
obj/Debug/Dropbox/Codes/K2/K2ohms.o obj/Debug/Dropbox/Codes/K2/K2collsee_ani.o
obj/Debug/Dropbox/Codes/K2/K2advectp_cubic.o obj/Debug/Dropbox/Codes/K2/K2advectp_chang.o
obj/Debug/Dropbox/Codes/K2/K2evolveEB.o obj/Debug/Dropbox/Codes/K2/K2advectx_ppm.o
obj/Debug/Dropbox/Codes/K2/K2smooth.o obj/Debug/Dropbox/Codes/K2/K2hybrid.o
obj/Debug/Dropbox/Codes/K2/K2grid.o obj/Debug/Dropbox/Codes/K2/K2advectyr2.o
obj/Debug/Dropbox/Codes/K2/K2collsii.o obj/Debug/Dropbox/Codes/K2/K2unused.o
obj/Debug/Dropbox/Codes/K2/K2momentsi.o obj/Debug/Dropbox/Codes/K2/K2colls_ee_gyor.o
obj/Debug/Dropbox/Codes/K2/K2single.o obj/Debug/Dropbox/Codes/K2/K2initial_calcs.o
obj/Debug/Dropbox/Codes/K2/K2calcGH.o obj/Debug/Dropbox/Codes/K2/K2moments.o
obj/Debug/Dropbox/Codes/K2/K2advecty_rot.o obj/Debug/Dropbox/Codes/K2/K2advectx.o -I/usr/local/dislin/ifc/ -lm
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 0 has invalid symbol index 10
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 1 has invalid symbol index 11
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 2 has invalid symbol index 2
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 3 has invalid symbol index 2
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 4 has invalid symbol index 10
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 5 has invalid symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 6 has invalid symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 7 has invalid symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 8 has invalid symbol index 2
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 9 has invalid symbol index 2
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 10 has invalid symbol index 11
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 11 has invalid symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 12 has invalid symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 13 has invalid symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 14 has invalid symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 15 has invalid symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 16 has invalid symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 17 has invalid symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 18 has invalid symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 19 has invalid symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 20 has invalid symbol index 19
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 15 seconds)
1 errors, 0 warnings (0 minutes, 15 seconds)
答案 0 :(得分:1)
我从忘记添加主程序的目标文件(以program foo
;-)开头的情况)的情况下知道这个错误。难道你也错过了那个吗?