Linux上的编译器选项框在ifort中 [英] compiler options on linux box in ifort

查看:514
本文介绍了Linux上的编译器选项框在ifort中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ifort,并在尝试使用编译器选项编译我的程序时收到链接错误。尽管如此,我已经在一个非常小的简单程序上测试了这些选项,我也遇到了同样的问题。

因此,我怀疑它与ifort的安装方式或我使用的系统类型有关,但我无法确定。这些程序在没有选项的情况下编译时可以正常编译。我的问题是我在做什么错了有没有办法在使用编译器选项或编译器选项时出现这些错误,这些选项与我使用的系统不兼容。



  ifort -free testrealprint.out testrealprint.f90 

code>

这里是程序编译时的选项:

  ifort -free -O2 -stand f03 -check all -traceback -warn all -fstack-protector  -  assume protect_parens -implicitnone testrealprint.out testrealprint.f90 

这里是我用来测试编译器选项的非常简单的代码:

 程序主

隐含无

实数,维(1:3):: adremvect
整数:: j
字符(LEN = 7):: adremchar,adremcharadj,adremcharadjtrm,adremcharnew
adremvect =(/ 2.0,1.3,1.0 /)
do j = 1,3
写(adremchar,'(f5.1)')adremvect(j)
adremcharadj = adjustl(adremchar)
adremcharadjtrm = trim(adremcharadj)
adremcharnew = adremchar(4 :)
print *,adremvect(j),adremcharadj,adremcharadjtrm,adremcharnew
end do

这里是在我使用编译器选项时收到的部分错误消息:

  testrealprint.out:在函数`_start'中:
(.text + 0x0):`_start'的多重定义
/usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../../../lib64 /crt1.o:(.text+0x0):首先在这里定义
testrealprint.out:在函数`_fini'中:
(.fini + 0x0):`_fini'的多重定义
/usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../../../lib64/crti.o:(.fini+0x0):首先在这里定义
testrealprint .out :(。rodata + 0x0):`_IO_stdin_used'的多重定义
/usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../../../lib64 /crt1.o:(.rodata.cst4 + 0x0):fi首先在这里定义
testrealprint.out:函数`__data_start':
(.data + 0x0):`__data_start'的多重定义
ld:testrealprint.out(.eh_frame)中的错误;没有.eh_frame_hdr表将被创建。


解决方案

看起来非常像缺少命令行用于命名编译器发出的可执行文件的选项。我假设你真的想要这样的东西(注意 -o 选项):

  ifort -free -O2 -stand f03 -check all -traceback -warn all -fstack-protector -assume protect_parens -implicitnone -o testrealprint.out testrealprint.f90 

您看到的错误可能是因为您正在告诉编译器通过编译 testrealprint.f90 然后将其与现有的可执行文件 testrealprint.out 链接起来。这就是为什么你从链接器中获取重复的符号错误 - 你试图将现有的应用程序链接到当前的链接器调用中。如果在搜索路径中没有存在 testrealprint.out 的情况下尝试编译时,您没有发现文件未找到错误,我感到有点惊讶。


I am using ifort and am getting a linking error when I attempt to compile my programs with compiler options. Nevertheless, I have tested out these options on a very small simple program I get the same issue.

I suspect therefore that it has to do with the way that ifort was installed or the type of system that I am using but I can't be sure. These programs compile alright when they are compiled with no options. My question is what am I doing wrong is there a way not to have these errors while using the compiler options or the compiler options simply not compatible with the system that I am using.

here is how the program is compiled regularly:

 ifort -free  testrealprint.out testrealprint.f90

here is how the program is compiled with options:

    ifort -free  -O2 -stand f03 -check all -traceback -warn all -fstack-protector -    assume protect_parens -implicitnone testrealprint.out testrealprint.f90

here is the very simple code that I am using to test the compiler options:

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

here is part of the error message that i receive when I use the compiler options:

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.

解决方案

It looks very much like you are missing a command line option for naming the executable emitted by the compiler. I presume you actually want something like this (note the -o option):

ifort -free  -O2 -stand f03 -check all -traceback -warn all -fstack-protector -assume protect_parens -implicitnone -o testrealprint.out testrealprint.f90

The error you are seeing is probably because you are telling the compiler to try making an executable by compiling testrealprint.f90 and then linking it with the existing executable testrealprint.out. This is why you are getting duplicate symbol errors from the linker - you are trying to link an existing application into the current linker call. I am kind of surprised that you are not getting a file not found error when trying the compilation without an existing testrealprint.out in the search path....

这篇关于Linux上的编译器选项框在ifort中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆