MSYS2,gfortran,gcc与fsync错误未定义的引用

时间:2019-03-14 20:41:52

标签: msys2

编译程序时(我将MSYS2与gcc和gfortran编译器一起使用。 )我遇到此错误:

  

fsync的未定义引用    代码的开始如下:

    #include <stdio.h>
    #include <stdlib.h>
    #include <math.h>
    #include <string.h>
    #include <time.h>
    #include <sys/types.h>
    #include <sys/stat.h>
    #include <unistd.h>
    #include "openmx_common.h"
    #include "mpi.h"
    #include <omp.h>



    double OutData(char *inputfile)
    {
      char operate[YOUSO10];
      int i,c,fd;
      int numprocs,myid;
      char fname1[300];
      char fname2[300];
      FILE *fp1,*fp2;
      char buf[fp_bsize];         
      char buf1[fp_bsize];         
      char buf2[fp_bsize];         
      double Stime,Etime;

      MPI_Comm_size(mpi_comm_level1,&numprocs);
      MPI_Comm_rank(mpi_comm_level1,&myid);

      ...

          for (i=0; i<numprocs; i++){ 

            sprintf(fname1,"%s%s.Dos.vec",filepath,filename);
            fp1 = fopen(fname1,"ab");
            fseek(fp1,0,SEEK_END);
            sprintf(fname2,"%s%s.Dos.vec%i",filepath,filename,i);
            fp2 = fopen(fname2,"rb");

            if (fp2!=NULL){
              for (c=getc(fp2); c!=EOF; c=getc(fp2))  putc(c,fp1); 
              fd = fileno(fp2); 
              fsync(fd); //??
          fclose(fp2); 
            }
            fd = fileno(fp1); 
            fsync(fd);  //??
            fclose(fp1); 
          }

是什么原因? 谢谢

0 个答案:

没有答案