Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28446 Discussions

command line compile error on the MAC console

gao__zhiming
Beginner
501 Views

  I try to build the Fortran code containing several fortran files with modules. I run it like this :

ifort -c constant.f90 CommonSub.f90 typedef.f90 globals.f90 output.f90 Prepro.f90 mesh3d.f90 ccfluids.f90 RMHD3D.f90 

ifort -o MHD constant.o CommonSub.o typedef.o globals.o output.o Prepro.o mesh3d.o ccfluids.o RMHD3D.o

It open the following error:

ld: can't link with a main executable file 'constant.o' for architecture x86_64

How can I fix this problem ??

 

PS:

The version of Intel Fortran compiler on Mac machine :

$ ifort -V

Intel(R) Fortran Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 19.0.0.117 Build 20180804

Copyright (C) 1985-2018 Intel Corporation.  All rights reserved.

 

 

0 Kudos
2 Replies
Steve_Lionel
Honored Contributor III
501 Views

A bit of Googling suggests that constant.o is already linked as an executable file. How sure are you that you used -c on the first line?

0 Kudos
mecej4
Honored Contributor III
501 Views

Your command lines are fine. Simply remove the nine .o files, recompile and relink. The problem should go away.

0 Kudos
Reply