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

error LNK2005

KaufmanFortran
Beginner
1,373 Views

I'm new to Fortran 2020 and cannot get a new project compiled. The old ones that were converted are fine. I have my own libraries that work on the old programs, but I get multiple LNK2005 errors (attached). I've read the other comments but cannot figure out how to modify the command or whatever statements to avoid conflicts. I'm attaching the error output. Thank you!

Labels (1)
0 Kudos
1 Solution
mecej4
Honored Contributor III
1,368 Views

You have a mix of object files (separately or in libraries) that the linker is being asked to use to produce an EXE or DLL. Some of the objects were compiled with /MD, some with /MT (or the equivalent /libs: options in IFort). Similar problems arise if some objects were produced by one version of the compiler and others with a different version.

Rectify by recompiling all sources with the same /M? option. If that is not possible (because you do not have the Fortran or C sources to some object files or libraries), you may try the linker option /force:multiple, but that does not always work.

When you reply, it will be easier for readers here if you post error messages as text in the body of the post rather than attaching screenshots.

View solution in original post

0 Kudos
1 Reply
mecej4
Honored Contributor III
1,369 Views

You have a mix of object files (separately or in libraries) that the linker is being asked to use to produce an EXE or DLL. Some of the objects were compiled with /MD, some with /MT (or the equivalent /libs: options in IFort). Similar problems arise if some objects were produced by one version of the compiler and others with a different version.

Rectify by recompiling all sources with the same /M? option. If that is not possible (because you do not have the Fortran or C sources to some object files or libraries), you may try the linker option /force:multiple, but that does not always work.

When you reply, it will be easier for readers here if you post error messages as text in the body of the post rather than attaching screenshots.

0 Kudos
Reply