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
Solved

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

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to gracefully close the c++ 11 thread? 3 108
Header of docx file 17 115
passing data from one form to another form in c++ 27 83
Link failure 16 34
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

828 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