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

error lnk2005: __matherr already defined in LIBCMTD.lib

kevin_l_johnson
Beginner
1,055 Views
My current project has a souce code writtenin VC++ .NET which calls a couple of Fortran subroutines. The program has been compiling and linking without any problems. Execution of the code has been great as well. The code performs math functions from the "cmath" library (pow, %, *, /, etc). However, today I inserted "atan2" (arc tangent of 2 variables) into the VC++ source code; everything compiled just fine, but when I tried to "Build" the project, I received the error message in the Subject line above. Does this mean there's a definition for "atan2" in the fortran libraries?
Thanks,
Kevin
0 Kudos
5 Replies
Steven_L_Intel1
Employee
1,055 Views
No, but because of an unfortunate choice MS made in the way they package their libraries, you can run into this if you use math routines in both languages.
The usual workaround is to make sure that the Fortran library containing a version of __matherr links first. In your case, that means adding DFORMT.LIB to the beginning of the list of libraries in the Link project options tab.
0 Kudos
kevin_l_johnson
Beginner
1,055 Views
I'm having trouble finding where to specificy the order of the libraries to link together. I'm using VC++ .NET. I have found the "command line" option under the "linker" tab which lists the different libraries to link, but I can't seem to modify the order of this list.
Thanks,
Kevin
0 Kudos
Steven_L_Intel1
Employee
1,055 Views
Linker..Input..Additional Dependencies.
0 Kudos
kevin_l_johnson
Beginner
1,055 Views

Ok...I have inserted "dformt.lib" into the "Additional Dependencies" line and my "Command Line" now looks like this:

/OUT:"D:datagz56543My DocumentsC-5codesFTDRTClimbDebugClimbFTDRT.exe" /INCREMENTAL /NOLOGO /LIBPATH:"D:datagz56543Microsoft Visual Studiodf98LIB" /DEBUG /ASSEMBLYDEBUG /PDB:"D:datagz56543My DocumentsC-5codesFTDRTClimbDebug/ClimbFTDRT.pdb" /FIXED:No dformt.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib "datagz56543Microsoft Visual Studiodf98LibDformt.lib"

However, I still get the "__matherr already defined in LIBCMTD.lib" message. After getting this error message, I tried inserting into the "Delay Loading DLL's" space the file "LIBCMTD.lib" but to no avail.

Kevin

0 Kudos
Steven_L_Intel1
Employee
1,055 Views
Things do get messy trying to combine CVF and VC.NET. One thing is that LIBCMTD is a static multithread debug library, and has nothing to do with DLLs. Perhaps try building the C code using the non-debug CMT library?
0 Kudos
Reply