Link to home
Start Free TrialLog in
Avatar of cw43
cw43

asked on

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

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
Avatar of sprinkmeier
sprinkmeier

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
Avatar of cw43

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of LarsC
LarsC
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial