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

Already Defined Link Error

kstedman9
Beginner
1,197 Views

Hello All,

I am having a problem linking a program that has both fortran and C code associated with it. Both the C code and the fortran are making calls to log10 function. When it goes to link it, the linker is returning this error:

LIBCMT.lib(log10.obj) : error LNK2005: _log10 already defined in libmmt.lib(log10_stub.omu)

What is causing this erroror how doI correct it?

Kevin

0 Kudos
6 Replies
TimP
Honored Contributor III
1,197 Views
Someone may be able to give better answers, if you give more information. If you are working with 32-bit code, you would have the opportunity to set non-threaded options under one language and threaded in the other. Then,your linkmight searchboth kinds of libraries, producing such a conflict.
0 Kudos
kstedman9
Beginner
1,197 Views

What other information would you like to see? This code will be used on both 32 bit and 64 bit platforms. I currently compiling on 32 bit. Both libraries are from the static multi-threaded libraries and I have my flags set appropriatly for this.

I am using Visual Studio 2005 SP1 for the C compiler and Intel Visual Fortran 9.1 for the fortran compiler.

Kevin

0 Kudos
Steven_L_Intel1
Employee
1,197 Views
Tim has the right idea. Compare the settings for the run-time libraries to use between the property page Code Generation (C++) and Libraries (Fortran). They need to match. If C++ is specifying "Multithreaded (/MT)" then Fortran needs to have "Multithreaded" set too.
0 Kudos
kstedman9
Beginner
1,197 Views

Well here are my compile flags so that you can see for yourself. That was the first thing I checked.

C Compile flags:

/GL /MT /openmp /W3 /nologo /Wp64 /O2 /DWIN32 /DNDEBUG /D_LIB /D_CRT_SECURE_NO_DEPRECATE /D_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES /D_CRT_NONSTDC_NO_DEPRECATE

Fortran Compile Flags:

/O2 /extend_source:132 /fpp /compile_only /real_size:32/MT /names:lowercase /DWIN32

It is only the log10 function call that I can see that does it. I use many other calls from the math libraries and do not have this problem with them.

0 Kudos
TimP
Honored Contributor III
1,197 Views
I would be concerned about compatibility of some of those Microsoft options with a mixed Microsoft/Intel build. In particular, I doubtthat whole program optimization would work, and the Microsoft openmp has been documented as incompatible with Intel openmp.
0 Kudos
Steven_L_Intel1
Employee
1,197 Views
I think I see now. Does your C code also call log10? Try this. Add libmmt.lib to the command that links the program. The idea is to get libmmt searched first.
0 Kudos
Reply