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

Library Problems on C++ and Fortran Mixed Language Program

g0301117
Beginner
649 Views
I am mixing Visual C++ 6 Visual Fortran 6.6 by calling Fortran subroutines with a C++ main program. I am getting this math error when building it. The error is as follows:
dfor.lib(matherr.obj) : error LNK2005: __matherr already defined in LIBCD.lib(matherr.obj)
Debug/ExampC4.exe : fatal error LNK1169: one or more multiply defined symbols found
Error executing link.exe.


I have searched the help pages and have not found any help. The project settings for my project are below.

The Project Settings for Link are:
kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.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 /nologo /subsystem:console /incremental:yes /pdb:"Debug/test.pdb" /debug /machine:I386 /out:"Debug/test.exe" /pdbtype:sept 

The Project Settings for Fortran are:
/check:bounds /compile_only /dbglibs /debug:full /nologo /traceback /warn:argument_checking /warn:nofileopt /module:"Debug/" /object:"Debug/" /pdbfile:"Debug/DF60.PDB" 


The Project Settings for C++ are:
/nologo /MLd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Fp"Debug/test.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c 

Does anyone know what might be the problem?
Thank youvery much!
0 Kudos
7 Replies
TimP
Honored Contributor III
649 Views
I suppose you are linking math libraries both from your C++ and your Fortran code.
If you were lucky, you might succeed by excluding libcd.lib from the link, hoping that
dfor.lib can take care of the references from C++.
While this forum is a good place to find experts on such problems, you may be aware
that HP took responsibility for CVF support away from Intel, so these compiler versions
appear headed for orphan status.
0 Kudos
Steven_L_Intel1
Employee
649 Views
We still welcome CVF questions here, however.
The usual solution to this problem is to explicitly add dfor.lib to the list of libraries in the Link tab.
0 Kudos
g_f_thomas
Beginner
649 Views
"We still welcome CVF questions here, however."

That's reassuring, Steve. IVF is coming along nicely but it hasn't been in the running as long as D(C)VF. I'm sure that there are IVF customers who have stabilized D(C)VF applications without ever intending to ever migrate them to IVF.

BTW, how does D(C)VF matherr.obj differ from MSCV's matherr.obj? BION, matherr is the singular omission from the MSCV CRT source.

Ciao,
Gerry T.
0 Kudos
g0301117
Beginner
649 Views
Thanks for your quick reply! But how can I add dfor.lib to the list of libraries?
0 Kudos
Steven_L_Intel1
Employee
649 Views
Project..Settings..Link. In the field of additional libraries/objects, put dfor.lib first in the list.
0 Kudos
g0301117
Beginner
649 Views
Thank you, steve. I cannot find the item of dfor.libin the field of object/libraries. Is that the problem of my version?
0 Kudos
fkaisermnb
Beginner
649 Views

You have to add the dfor.lib by yourself. Just type itat the beginning of the list.

Christian

0 Kudos
Reply