Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!

error LNK2005

KaufmanFortran
Beginner
223 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
Black Belt
217 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

1 Reply
mecej4
Black Belt
218 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

Reply