Solved

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

Posted on 1998-03-13
3
398 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
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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
count11 challenge 6 70
Least Squares Curve Fitting 4 77
What is sub-make ? 2 60
Advice in Xamarin 21 79
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
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…
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

770 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