0

我正在尝试使用 intel oneapi 编译器 (ifort -v 2021.2.0) 编译一些 Fortran 代码,并将其与之前编码的另一个 Fortran 库 (MultiZ) 链接。我正在使用以下生成文件:

# User parameters

LIBPATHS  = /RouteToLibrary/
LIBFLAGS  = -lmultiz

# Options. 1: use gfortran. 2: use ifort.
OP = 2

# Fortran compilers

# GFC: GNU Fortran Compiler
# IFC: Intel Fortran Compiler
GFC = gfortran
IFC = ifort

# Common flags

# -g:     Produce symbolic debug information.
# -c:     Compile to object (.o) only, do not link.
# -pg:    Profile with gprof

DEBUG   = -g
FCFLAGS = -c $(DEBUG) -pg
FLFLAGS =

# GNU Fortran Flags

GFCFLAGS = -fdefault-real-8 -fdefault-double-8 -Wall -pedantic -std=f2008 
GFLFLAGS = 

# Intel Fortran Flags

# IFCFLAGS = -autodouble -warn
IFCFLAGS = -warn
IFLFLAGS = 

# Lists and variables

ifeq ($(OP),1)
  FC      := $(GFC)
  FCFLAGS := $(FCFLAGS) $(GFCFLAGS)
  FLFLAGS := $(FLFLAGS) $(GFLFLAGS)
else
  FC      := $(IFC)
  FCFLAGS := $(FCFLAGS) $(IFCFLAGS)
  FLFLAGS := $(FLFLAGS) $(IFLFLAGS)
endif

# List of example files, objects and executables.
FILES := $(wildcard *.f90)
OBJS  := $(patsubst %.f90, %.o,   $(FILES))
EXEC  := $(patsubst %.f90, %.exe, $(FILES))

# List of filenames without extension.
NOEX  := $(subst .f90,,$(FILES))

LPATHS := $(foreach PATH, $(LIBPATHS), -L$(realpath $(PATH)))
IPATHS := $(foreach PATH, $(LIBPATHS), -I$(realpath $(PATH)))

define MAKE_EXE
  $1.exe : $1.o ; $(FC) $(FLFLAGS) $(LPATHS) $1.o $(LIBFLAGS) -o $1.exe
endef

# Rules.

all : $(EXEC)

$(foreach f, $(NOEX), $(eval $(call MAKE_EXE, $f)))

%.o : %.f90
    $(FC) $(FCFLAGS) $(IPATHS) $< -o $@

clean :
    rm -f $(EXEC) $(OBJS)

但是,我收到以下错误消息:

/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
MyMainScript.o: In function `MyFunction_':

在一些警告消息之后,会显示以下错误消息:

collect2: error: ld returned 1 exit status
make: *** [MyMainScript] Error 1
4

0 回答 0