Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ubuntu gfortran编译对象文件错误crt1.o:在函数“u start”中:_Ubuntu_Gcc_Fortran_Gfortran - Fatal编程技术网

Ubuntu gfortran编译对象文件错误crt1.o:在函数“u start”中:

Ubuntu gfortran编译对象文件错误crt1.o:在函数“u start”中:,ubuntu,gcc,fortran,gfortran,Ubuntu,Gcc,Fortran,Gfortran,我编译了一个fortran文件,并创建了一个目标文件。之后我试图执行目标文件,但出现了一个错误。操作系统是Ubuntu,错误如下: 编译源文件 gfortran -O3 reader.f iotools.c -o reader.x 执行对象文件 gfortran reader.o 错误呢 /usr/lib/gcc/x86_64-linux-gnu/5/./../../../x86_64-linux-gnu/crt1.o:In 函数_start':.text+0x20:未定义的引用tomain

我编译了一个fortran文件,并创建了一个目标文件。之后我试图执行目标文件,但出现了一个错误。操作系统是Ubuntu,错误如下:

编译源文件

gfortran -O3 reader.f iotools.c -o reader.x
执行对象文件

gfortran reader.o
错误呢

/usr/lib/gcc/x86_64-linux-gnu/5/./../../../x86_64-linux-gnu/crt1.o:In 函数_start':.text+0x20:未定义的引用tomain' reader.o:在函数MAIN__;中:fort77-2624-1.c:.text+0xf:未定义 参考READC_'fort77-2624-1.c:.text+0x278:未定义 参考s_wsle'fort77-2624-1.c:.text+0x291:未定义 参考todo_lio'fort77-2624-1.c:.text+0x2aa:未定义 参考do_lio'fort77-2624-1.c:.text+0x2c3:未定义 参考todo_lio'fort77-2624-1.c:.text+0x2c8:未定义 对“e_wsle”集合2的引用:错误:ld返回1退出状态

reader.f文件

ccccccccccccccccccccccccccccccccccccccccccccccccccccccc
C  Basic fortran (and c tools) code to read fMRI images
C  Compile linux:g77 -O3 reader.f iotools.c -o reader.x
c  In Cygwin compile as : (to prevent max memory bug)
c  g77 -o reader.x -Wl,--stack,8388608 reader.f iotools.c
c   Execute:  reader.x < imagename.img
c   where "imagename.img" is a huge image fmri file
c------------------------------------------------------
c   Standard output: the full correlation matrix
c------------------------------------------------------
      parameter(maxsites=147456,maxtime=400,mintime=1)
      real a(maxsites*maxtime), b(maxsites*maxtime)
      real*8 ax, sxx(maxsites), sxy, r
      integer iflag(maxsites)

c....   Read image file into a
      i=ireadc(a,4*maxsites*maxtime)
      do ix=1, maxsites
        do it=1, maxtime
      b((ix-1)*maxtime+ it) = a((it-1)*maxsites + ix)
        enddo
      enddo

        do ix=1, maxsites
        iflag(ix)=0
        ax=0.d0
        sxx(ix)=0.d0
            do it=mintime, maxtime
            ax=ax + dble(b((ix-1)*maxtime + it))
            enddo   
        ax=ax/dfloat(1+maxtime-mintime)! mean activity for this voxel
        if(ax.gt.7000.d0.and.ax.lt.14000) then
          iflag(ix)=1                   ! flag the usefull voxels
          do it=mintime, maxtime
        ic=(ix-1)*maxtime + it
        b(ic)   =  b(ic) - ax
        sxx(ix) = sxx(ix) + dble(b(ic)*b(ic))
          enddo 
        endif
      enddo 
c--------------------------------------------------------------
       do l1=1, maxsites-1
         if(iflag(l1).eq.1) then
      do l2=l1+1, maxsites
        if(iflag(l2).eq.1) then
              sxy=0.d0
          do it=mintime, maxtime
            ic1 = (l1-1)*maxtime + it
            ic2 = (l2-1)*maxtime + it
            sxy = sxy + dble(b(ic1)*b(ic2))
          enddo
          r=sxy/dsqrt(sxx(l1)*sxx(l2))!linear l1-l2 correlation
          write(*,*) l1,l2,r
        endif
      enddo
    endif
      enddo


      end
您当然不会执行object.o文件。您可以将其链接以创建可执行文件

但请注意,您没有创建reader.o文件,而是在以下位置创建reader.x文件:

使用此命令,应该创建一个可执行文件reader.x,并且您应该能够执行它。没有第二个gfortran命令

你可以分两步来做。首先编译,然后链接

gfortran -c -O3 reader.f iotools.c -o reader.o

gfortran reader.o
在本例中,第二个命令创建一个名为a.out的可执行文件

这两种方法都是可能的


这些都是绝对的基础,在尝试更多之前,请先做一些研究。阅读教程,在那里的问题中搜索。这里有许多非常相似的问题。我在这里回答只是为了澄清您的具体困惑,这些困惑可能无法从一些副本中直接清楚地看到。

源文件和教授给出的命令。所以我应该是gfortran-c-O3 reader.f iotools.c-o reader.x?这并不重要,很明显,它们是错误的,或者是您复制了错误的。你的代码中有主程序吗?还是一个主要功能?代码是什么样子的?是的,您应该在那里有-c标志和-o reader.o。或者您应该跳过第二个命令.gfortran-c reader.o?不,一点也不。执行:reader.xgfortran -c -O3 reader.f iotools.c -o reader.o gfortran reader.o