我使用ifort,并且在尝试编译带编译器选项的程序时出现链接错误。尽管如此,我已经在一个非常小的简单程序上测试了这些选项,我也遇到了同样的问题。在ifort的linux上的编译选项
因此,我怀疑它与安装ifort的方式或我正在使用的系统类型有关,但我无法确定。这些程序在没有选项的情况下编译时可以正常编译。我的问题是我在做什么错了有没有一种方法,当使用编译器选项或编译器选项,而不是与我使用的系统不兼容时,有这些错误。
这里是怎样的程序定期编制:
ifort -free testrealprint.out testrealprint.f90
这里是如何在程序编译选项:
ifort -free -O2 -stand f03 -check all -traceback -warn all -fstack-protector - assume protect_parens -implicitnone testrealprint.out testrealprint.f90
这里是非常简单的代码,我使用测试编译器选项:
program main
implicit none
real, dimension(1:3) :: adremvect
integer :: j
character (LEN = 7) :: adremchar, adremcharadj,adremcharadjtrm, adremcharnew
adremvect = (/ 2.0, 1.3, 1.0 /)
do j = 1, 3
write(adremchar, '(f5.1)') adremvect(j)
adremcharadj = adjustl(adremchar)
adremcharadjtrm = trim(adremcharadj)
adremcharnew = adremchar(4:)
print *, adremvect(j), adremcharadj, adremcharadjtrm, adremcharnew
end do
这里是我收到的错误消息的一部分,当我使用th e编译器选项:
testrealprint.out: In function `_start':
(.text+0x0): multiple definition of `_start'
/usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../../../lib64/crt1.o:(.text+0x0): first defined here
testrealprint.out: In function `_fini':
(.fini+0x0): multiple definition of `_fini'
/usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../../../lib64/crti.o:(.fini+0x0): first defined here
testrealprint.out:(.rodata+0x0): multiple definition of `_IO_stdin_used'
/usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../../../lib64/crt1.o: (.rodata.cst4+0x0): first defined here
testrealprint.out: In function `__data_start':
(.data+0x0): multiple definition of `__data_start'
ld: error in testrealprint.out(.eh_frame); no .eh_frame_hdr table will be created.
您是否试图让编译器命名最终的可执行文件为'testrealprint.out '? – talonmies 2012-04-09 14:36:13
是的,我很努力。 – 2012-04-09 14:45:18