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

Mixed VC++ and VFortrant problems

ohadg1
Beginner
319 Views

Hi,

I'm new in this thing, so be gentle with me...

I wrote a mixed Fortran and VC++ code (The VC++ calls the Fortran routines).

When I'm using a mathematical function (e.g. tan,cos etc.) in my C++ code I get the following error message:

dfor.lib(matherr.obj) : error LNK2005: __matherr already defined in LIBCD.lib(matherr.obj)

According to a search on the web I should include dfor.lib inside my linking libraries of the C++ project, but still I get this message.

My C++ linking definitions are:

dfor.lib FortranMain.lib /nologo /subsystem:windows /incremental:yes /pdb:"Debug/TBWmain.pdb" /debug /machine:I386 /nodefaultlib:"msvcrtd.lib"

My Fortran compilation setting are:

/check:bounds /compile_only /debug:full /include:"Debug/" /nologo /traceback /warn:argument_checking /warn:nofileopt /module:"Debug/" /object:"Debug/" /pdbfile:"Debug/DF60.PDB"

Thanks for any help!

OG

0 Kudos
1 Reply
Steven_L_Intel1
Employee
319 Views
You have what we call "Mixed C Library Syndrome". Your C++ and Fortran projects are specifying different kinds of C++ libraries. That you added /nodefaultlib is an indication of this. Remove it.

It is the compilation settings that are most important. The run-time library type must match between Fortran (Libraries) and C++ (Code Generation). If you are building a Debug configuration, then "Single-Threaded Debug (/ML)" will probably work for you. (You are using CVF - if you were using Intel Fortran I would recommend "Multithreaded Debug" as the single-threaded static libraries don't exist in VS2005 or later.)
0 Kudos
Reply