Solved

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

Posted on 1998-03-13
3
402 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 2

Expert Comment

by:sprinkmeier
ID: 1183447
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
ID: 1183448
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
ID: 1183449
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

726 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