Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
199 views
in Technique[技术] by (71.8m points)

linker - compiler options on linux box in ifort

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.
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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....


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...