Software Archive
Read-only legacy content
17061 Discussions

Link err: matherr defined in dformt.lib and libcmtd.lib

dwelter
Beginner
705 Views
I have been working on an a Visual C++ program which I want to statically link to several FORTRAN routines. I have read the previous posts on mixed language programming and believe that I an using the correct libraries. On the C++ side I am using libcmtd.lib and on the FORTRAN side I am using dformt.lib. In fact I was sucessful in compiling my program when I did not include the C++ header file or use any of the routines contained in it. Once I included started using it's routines I got link errors that indicate the function matherr is defined in both dformt.lib and libcmtd.lib. Is there something I am doing wrong or is this a bug in the libraries? Either way is there some way I can get around this. I would really appreciate any help you can provide me as I am trying to meet a tight deadline on this project.

Thanks,
Dave Welter
0 Kudos
12 Replies
Steven_L_Intel1
Employee
705 Views
Project..Settings..Link In the list of libraries/objects to include, add DFORMT.LIB at the front of the list. That should do it. The key is to make sure that DFORMT.LIB is searched first. (Note that if you're NOT building with the threaded libraries, use DFOR.LIB instead.)

Steve
0 Kudos
dwelter
Beginner
705 Views
Thanks for your reply. I put dformt.lib in as the first item in the list of object to include but I am still experencing the same problem. Attached is the beginning of verbose output from the linker for a simple test program which replicates the problem. Could "Processed /DEFAULTLIB:LIBCMTD" be causing the linker not to look at dformt.lib first?

Dave

Linking...
Start Pass1
Processed /DEFAULTLIB:LIBCMTD
Processed /DEFAULTLIB:OLDNAMES
Processed /DEFAULTLIB:libcpmtd
Searching Libraries
Searching C:Program FilesMicrosoft Visual StudioDF98Libdformt.lib:
Searching C:Program FilesMicrosoft Visual StudioVC98Libkernel32.lib:
Searching C:Program FilesMicrosoft Visual StudioVC98Libuser32.lib:
Searching C:Program FilesMicrosoft Visual StudioVC98Libgdi32.lib:
Searching C:Program FilesMicrosoft Visual StudioVC98Libwinspool.lib:
Searching C:Program FilesMicrosoft Visual StudioVC98Libcomdlg32.lib:
Searching C:Program FilesMicrosoft Visual StudioVC98Libadvapi32.lib:
Searching C:Program FilesMicrosoft Visual StudioVC98Libshell32.lib:
Searching C:Program FilesMicrosoft Visual StudioVC98Libole32.lib:
Searching C:Program FilesMicrosoft Visual StudioVC98Liboleaut32.lib:
Searching C:Program FilesMicrosoft Visual StudioVC98Libuuid.lib:
Searching C:Program FilesMicrosoft Visual StudioVC98Libodbc32.lib:
Searching C:Program FilesMicrosoft Visual StudioVC98Libodbccp32.lib:
Searching d:/Data/projects/cascade/cascade/debugcascade.lib:
Found _CASCADE@16
Referenced in testPrjC.obj
Loaded cascade.lib(cascade.obj)
Processed /DEFAULTLIB:dformt.lib
Processed /DEFAULTLIB:dfconsol.lib
Processed /DEFAULTLIB:dfport.lib
Processed /DEFAULTLIB:kernel32.lib
Found _HEADING@0
Referenced in cascade.lib(cascade.obj)
Loaded cascade.lib(heading.obj)
Found _RDTWDW@8
Referenced in cascade.lib(cascade.obj)
Loaded cascade.lib(rdtwdw.obj)
Found _RDBASIN@12
Referenced in cascade.lib(cascade.obj)
Loaded cascade.lib(rdbasin.obj)
Found _RDSTRUC@12
Referenced in cascade.lib(cascade.obj)
Loaded cascade.lib(rdstruc.obj)
Found _RDSSWR@0
Referenced in cascade.lib(cascade.obj)
Loaded cascade.lib(rdsswr.obj)
Found _RDOFFSI@12
Referenced in cascade.lib(cascade.obj)
Loaded cascade.lib(rdoffsi.obj)
Found _SIMULA@8
Referenced in cascade.lib(cascade.obj)
Loaded cascade.lib(simula.obj)
Found _DSSTOR@8
Referenced in cascade.lib(cascade.obj)
Loaded cascade.lib(dsstor.obj)
Found _VSCURVE@16
Referenced in cascade.lib(simula.obj)
Loaded cascade.lib(vscurve.obj)
Found _RAINDIS@20
Referenced in cascade.lib(simula.obj)
Loaded cascade.lib(raindis.obj)
Found _SBUH@24
Referenced in cascade.lib(simula.obj)
Loaded cascade.lib(sbuh.obj)
Found _GCUH@28
Referenced in cascade.lib(simula.obj)
Loaded cascade.lib(gcuh.obj)
Found _OFFS@8
Referenced in cascade.lib(simula.obj)
Loaded cascade.lib(offs.obj)
Found _PUMPIT@12
Referenced in cascade.lib(simula.obj)
Loaded cascade.lib(pumpit.obj)
Found _RATNG@16
Referenced in cascade.lib(simula.obj)
Loaded cascade.lib(ratng.obj)
Found _GOPEN@12
Referenced in cascade.lib(simula.obj)
Loaded cascade.lib(gopen.obj)
Found _GATE@36
Referenced in cascade.lib(simula.obj)
Loaded cascade.lib(gate.obj)
Found _PIPE@20
Referenced in cascade.lib(simula.obj)
Loaded cascade.lib(pipes.obj)
Found _WEIRALL@32
Referenced in cascade.lib(simula.obj)
Loaded cascade.lib(weirall.obj)
Found _BLEED@52
Referenced in cascade.lib(simula.obj)
0 Kudos
dwelter
Beginner
705 Views
Thanks for your reply. I put dformt.lib in as the first item in the list of object to include but I am still experencing the same problem. Attached is the beginning of verbose output from the linker for a simple test program which replicates the problem. Could "Processed /DEFAULTLIB:LIBCMTD" be causing the linker not to look at dformt.lib first?

Dave

Linking...
Start Pass1
Processed /DEFAULTLIB:LIBCMTD
Processed /DEFAULTLIB:OLDNAMES
Processed /DEFAULTLIB:libcpmtd
Searching Libraries
Searching C:Program FilesMicrosoft Visual StudioDF98Libdformt.lib:
Searching C:Program FilesMicrosoft Visual StudioVC98Libkernel32.lib:
Searching C:Program FilesMicrosoft Visual StudioVC98Libuser32.lib:
Searching C:Program FilesMicrosoft Visual StudioVC98Libgdi32.lib:
Searching C:Program FilesMicrosoft Visual StudioVC98Libwinspool.lib:
Searching C:Program FilesMicrosoft Visual StudioVC98Libcomdlg32.lib:
Searching C:Program FilesMicrosoft Visual StudioVC98Libadvapi32.lib:
Searching C:Program FilesMicrosoft Visual StudioVC98Libshell32.lib:
Searching C:Program FilesMicrosoft Visual StudioVC98Libole32.lib:
Searching C:Program FilesMicrosoft Visual StudioVC98Liboleaut32.lib:
Searching C:Program FilesMicrosoft Visual StudioVC98Libuuid.lib:
Searching C:Program FilesMicrosoft Visual StudioVC98Libodbc32.lib:
Searching C:Program FilesMicrosoft Visual StudioVC98Libodbccp32.lib:
Searching d:/Data/projects/cascade/cascade/debugcascade.lib:
Found _CASCADE@16
Referenced in testPrjC.obj
Loaded cascade.lib(cascade.obj)
Processed /DEFAULTLIB:dformt.lib
Processed /DEFAULTLIB:dfconsol.lib
Processed /DEFAULTLIB:dfport.lib
Processed /DEFAULTLIB:kernel32.lib
Found _HEADING@0
Referenced in cascade.lib(cascade.obj)
Loaded cascade.lib(heading.obj)
Found _RDTWDW@8
Referenced in cascade.lib(cascade.obj)
Loaded cascade.lib(rdtwdw.obj)
Found _RDBASIN@12
Referenced in cascade.lib(cascade.obj)
Loaded cascade.lib(rdbasin.obj)
Found _RDSTRUC@12
Referenced in cascade.lib(cascade.obj)
Loaded cascade.lib(rdstruc.obj)
Found _RDSSWR@0
Referenced in cascade.lib(cascade.obj)
Loaded cascade.lib(rdsswr.obj)
Found _RDOFFSI@12
Referenced in cascade.lib(cascade.obj)
Loaded cascade.lib(rdoffsi.obj)
Found _SIMULA@8
Referenced in cascade.lib(cascade.obj)
Loaded cascade.lib(simula.obj)
Found _DSSTOR@8
Referenced in cascade.lib(cascade.obj)
Loaded cascade.lib(dsstor.obj)
Found _VSCURVE@16
Referenced in cascade.lib(simula.obj)
Loaded cascade.lib(vscurve.obj)
Found _RAINDIS@20
Referenced in cascade.lib(simula.obj)
Loaded cascade.lib(raindis.obj)
Found _SBUH@24
Referenced in cascade.lib(simula.obj)
Loaded cascade.lib(sbuh.obj)
Found _GCUH@28
Referenced in cascade.lib(simula.obj)
Loaded cascade.lib(gcuh.obj)
Found _OFFS@8
Referenced in cascade.lib(simula.obj)
Loaded cascade.lib(offs.obj)
Found _PUMPIT@12
Referenced in cascade.lib(simula.obj)
Loaded cascade.lib(pumpit.obj)
Found _RATNG@16
Referenced in cascade.lib(simula.obj)
Loaded cascade.lib(ratng.obj)
Found _GOPEN@12
Referenced in cascade.lib(simula.obj)
Loaded cascade.lib(gopen.obj)
Found _GATE@36
Referenced in cascade.lib(simula.obj)
Loaded cascade.lib(gate.obj)
Found _PIPE@20
Referenced in cascade.lib(simula.obj)
Loaded cascade.lib(pipes.obj)
Found _WEIRALL@32
Referenced in cascade.lib(simula.obj)
Loaded cascade.lib(weirall.obj)
Found _BLEED@52
Referenced in cascade.lib(simula.obj)
0 Kudos
Steven_L_Intel1
Employee
705 Views
I don't see the actual errors in your posting - just a bunch of status messages. If you haven't already, go to Project..Settings..Fortran..Libraries and check the "Use debug C libraries" box, since you're using those.

Steve
0 Kudos
isn-removed200637
705 Views
When I have found such problems in the past (matherr,obj and crt0dat.obj being duplicated duting library searches), I have used the library management tool FORTLIB to create a copy of LIBCMT (or whichever one is the problem) called, for example (choose your own) NEWLIBCMT.LIB, BUT WITH THE DUPLICATED ROUTINE(s) DELETED FROM THE NEW LIBRARY.

Include the name of this new library in your link list, deleting reference to the 'complete' one.

That should work.
0 Kudos
dwelter
Beginner
705 Views
I have had the "Use debug C libraries" box checked on the FORTRAN side from the beginning, but I has not done any good the actual error I getting is:

Linking...
dformt.lib(matherr.obj) : error LNK2005: __matherr already defined in LIBCMTD.lib(matherr.obj)
LINK : warning LNK4098: defaultlib "libcmt.lib" conflicts with use of other libs; use /NODEFAULTLIB:library
Debug/simplec.exe : fatal error LNK1169: one or more multiply defined symbols found
Error executing link.exe.

simplec.exe - 2 error(s), 1 warning(s)
0 Kudos
dwelter
Beginner
705 Views
Anthony, thnaks for your reply. Where did you get the FORTLIB utlity from? I wasn't able to find it in my Visual FORTRAN installation. Does it come bundled with Visual FORTRAN or is it a seperate product.

Dave
0 Kudos
isn-removed200637
705 Views
Hi,
I apologise - I quoted the wrong name - it's the library manager LIB that comes
with Visual Fortran.

You would use the command

LIB /REMOVE:matherr.obj /OUT:NEWLIBRARYNAMEHERE OLDLIBRARYNAMEHERE

best regards

Tony Richards
0 Kudos
david_jones
Beginner
705 Views
Some of the above is looking rather complicated. Since a similar problem has just happened to me, I thought I might report that my (apparently successful) solution was to add the offending C-library (libc.lib, libcd.lib, or whatever is complained about) to the list held under Project Settings - Link - Input - Ignore Libraries.

David Jones
0 Kudos
Steven_L_Intel1
Employee
705 Views
Please don't use the "ignore libraries" setting - it just hides the problem. This can always be solved by linking against the correct set of libraries. The article on "Multiple C Library Syndrome" in CVF newsletter issue 6 is helpful.

Steve
0 Kudos
david_jones
Beginner
705 Views
Given this prompt, I have now successfully sorted out at least one case of this with my projects ( a QuickWin project needing some of my own libraries). I had read the article previously, but had been confused by the article saying that QuckWin must be used with multithreaded libraries, whereas the quick-help for Project settings> Fortran> Libraries> Use Multi-Threaded Library contradicts this, and I had tended to believe the text apparently attached to the compiler.

A question remaining is what are the suggested settings for the Libraries panel, in the case of a project which creates a static library to be used by a Quickwin project. In particular the difference between checking the Use Multi-threaded libraries box and selecting QuickWin in the Use Run_Time Libraries box. Further, what is the relevance of the "Reentrancy Support" box in this context?
0 Kudos
Steven_L_Intel1
Employee
705 Views
I think that for a library to be used with QuickWin, the correct setting would be QuickWin, though Static with the Use MultiThreaded Libraries box checked might also work. The reentrancy option is used to specify whether or not the run-time library should protect itself against calls done in multiple threads - this shouldn't be necessary in QuickWin, which is always multithreaded.

Steve
0 Kudos
Reply