Solved

Linking error while calling a Fortain library from Visual C++ 5.0

Posted on 1998-03-13
3
386 Views
Last Modified: 2013-11-08
I am current creating a SDI application, which calls a user-defined Fortran library, mylib.lib.  I have put the correct path of mylib.lib into LINK option under project'setting.  Also, the way I call this library is like:

extern "C" void __stdcall myfunction();

However, while I compile this application, it gave me some error message like:

dfor.lib(matherr.obj) : error LNK2005: __matherr already defined in msvcrtd.lib(merr.obj)
libcd.lib(fpinit.obj) : error LNK2005: __ldused already defined in a previous module
libcd.lib(fpinit.obj) : error LNK2005: __fltused already defined in a previous module
libcd.lib(crt0dat.obj) : error LNK2005: _exit already defined in msvcrtd.lib(MSVCRTD.dll)
libcd.lib(crt0dat.obj) : error LNK2005: __exit already defined in msvcrtd.lib(MSVCRTD.dll)
libcd.lib(ieee87.obj) : error LNK2005: __controlfp already defined in msvcrtd.lib(MSVCRTD.dll)
libcd.lib(winxfltr.obj) : error LNK2005: __XcptFilter already defined in msvcrtd.lib(MSVCRTD.dll)
libcd.lib(crt0init.obj) : error LNK2005: ___xc_z already defined in msvcrtd.lib(cinitexe.obj)
libcd.lib(crt0init.obj) : error LNK2005: ___xc_a already defined in msvcrtd.lib(cinitexe.obj)
libcd.lib(crt0init.obj) : error LNK2005: ___xi_z already defined in msvcrtd.lib(cinitexe.obj)
libcd.lib(crt0init.obj) : error LNK2005: ___xi_a already defined in msvcrtd.lib(cinitexe.obj)
msvcrtd.lib(MSVCRTD.dll) : error LNK2005: __setmbcp already defined in libcd.lib(mbctype.obj)
LINK : warning LNK4098: defaultlib "msvcrtd.lib" conflicts with use of other libs; use /NODEFAULTLIB:library
LINK : warning LNK4098: defaultlib "libcd.lib" conflicts with use of other libs; use /NODEFAULTLIB:library
dfor.lib(DFORMAIN.OBJ) : error LNK2001: unresolved external symbol _MAIN__

It does not complain about mylib.lib, but not happy about those libraries which I have never called.  I suspect that there are some conflicts about Visual C++'s default libraries.  I don't really know what is going on here.  Is there anything I need to set up before I call a import library under SDI project?  Thanks.

Richard
0
Comment
Question by:cw43
3 Comments
 
LVL 2

Expert Comment

by:sprinkmeier
Comment Utility
I had a smilar problem once, different platform/compiler, but the answer was that the library I was linking in was using an old version of some system library. Somewhere else, I had misspelled a function name, and that was unresolved, and so the linkere brought up the last libraries it knew about (i.e. the old ones, which up to now were not loaded cos everything else had been resolved) and I had all sorts of wierd conflicts!

Hope this helps
0
 

Author Comment

by:cw43
Comment Utility
I think my problem is not this.  I am using Microsoft Visual Studio to compile the Fortain library and my C++ application (there is a Digital Fortran 90 compiler and Visual C++ compiler. Both run under Microsoft Visual Studio).  I have checked my spelling carefully, I did not find any mis-spelling in my C++ codes.  My current application is a SDI project.  However, if I simply use default project (a DOS project), it works.  So I don't why it gave me those error messages when I use a SDI projects.
0
 

Accepted Solution

by:
LarsC earned 100 total points
Comment Utility
The problem occures because the compiled files contains info of which library the linker should link to default.
You need to tell the linker not to link to the default libraries. There is a option for that. If you do that then you migth have to tell the linker which standard libraries it should link to else you will get alot of unresolved functions.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
fizzArray  challenge 1 47
method argument as final 1 62
Python multiple IF statements 4 68
Copy Files - Python 7 52
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This video teaches viewers about errors in exception handling.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now