简体   繁体   中英

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM