- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have created a static library using Intel's fortran compiler (ifl) and the xlib executables. In my C++ header file
-----------------------
extern "C" void _stdcall DSLUCS_(int & N, double *B, double *X, int & NELT,
int * IA, int * JA, double * A, int & ISYM, int & ITOL, double & TOL,
int & ITMAX, int & ITER, double & ERR, int & IERR, int & IUNIT, double *RWORK, int & LENW,
int *IWORK, int & LENIW);
--------------------------------
and in the cpp file I use
--------------
DSLUCS_(N,B,X,NELT,IA,JA,A,ISYM,ITOL,TOL,ITMAX,ITER,ERR,
IERR,IUNIT,RWORK,LENW,IWORK,LENIW);
---------------
I keep on getting the following error
------
rror LNK2001: unresolved external symbol _DSLUCS_@76
Release/Simulator.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
------------------
I have tried taking out the underscore from both cpp and header file and some other experimentation with upper and lower cases. I consistently get linking errors.
Please help.
Deepankar
-----------------------
extern "C" void _stdcall DSLUCS_(int & N, double *B, double *X, int & NELT,
int * IA, int * JA, double * A, int & ISYM, int & ITOL, double & TOL,
int & ITMAX, int & ITER, double & ERR, int & IERR, int & IUNIT, double *RWORK, int & LENW,
int *IWORK, int & LENIW);
--------------------------------
and in the cpp file I use
--------------
DSLUCS_(N,B,X,NELT,IA,JA,A,ISYM,ITOL,TOL,ITMAX,ITER,ERR,
IERR,IUNIT,RWORK,LENW,IWORK,LENIW);
---------------
I keep on getting the following error
------
rror LNK2001: unresolved external symbol _DSLUCS_@76
Release/Simulator.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
------------------
I have tried taking out the underscore from both cpp and header file and some other experimentation with upper and lower cases. I consistently get linking errors.
Please help.
Deepankar
Link Copied
9 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The default calling interface for IFL is cdecl, which you might consider using, if you have no strong preference. There is an option for compatibility with the default CVF interface, which is closer to what you are trying to use. I would expect to have to examine both .obj files with dumpbin in an attempt to sort out such a complex interface.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sorry. I tried using cdecl instead of stdcall it is still the same problem. Somwhow it cannto recognize the subroutine in Fortran library.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Isn't default name exporting in IFL in lowercase?
In any case, you can find out what's the actual symbol decoration by using:
Jugoslav
In any case, you can find out what's the actual symbol decoration by using:
dumpbin /symbols whatever.lib > output.txtand examining contents of output.txt.
Jugoslav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the tip. After using dumpbin utility at least the C++ code can see the correct symbol in the library (no trailing underscores). However, I get the following linking errors. Seems like there is a conflict with
MSVCRT.lib. How do I turn this off or bypass. Thanks for your help.
Linking...
LIBC.lib(crt0dat.obj) : error LNK2005: _exit already defined in MSVCRT.lib(MSVCRT.dll)
LIBC.lib(crt0dat.obj) : error LNK2005: __exit already defined in MSVCRT.lib(MSVCRT.dll)
LIBC.lib(crt0.obj) : error LNK2005: _mainCRTStartup already defined in MSVCRT.lib(crtexe.obj)
LIBC.lib(crt0init.obj) : error LNK2005: ___xc_z already defined in MSVCRT.lib(cinitexe.obj)
LIBC.lib(crt0init.obj) : error LNK2005: ___xc_a already defined in MSVCRT.lib(cinitexe.obj)
LIBC.lib(crt0init.obj) : error LNK2005: ___xi_z already defined in MSVCRT.lib(cinitexe.obj)
LIBC.lib(crt0init.obj) : error LNK2005: ___xi_a already defined in MSVCRT.lib(cinitexe.obj)
LIBC.lib(winxfltr.obj) : error LNK2005: __XcptFilter already defined in MSVCRT.lib(MSVCRT.dll)
LINK : warning LNK4098: defaultlib "MSVCRT" conflicts with use of other libs; use /NODEFAULTLIB:library
LINK : warning LNK4098: defaultlib "LIBC" conflicts with use of other libs; use /NODEFAULTLIB:library
MSVCRT.lib. How do I turn this off or bypass. Thanks for your help.
Linking...
LIBC.lib(crt0dat.obj) : error LNK2005: _exit already defined in MSVCRT.lib(MSVCRT.dll)
LIBC.lib(crt0dat.obj) : error LNK2005: __exit already defined in MSVCRT.lib(MSVCRT.dll)
LIBC.lib(crt0.obj) : error LNK2005: _mainCRTStartup already defined in MSVCRT.lib(crtexe.obj)
LIBC.lib(crt0init.obj) : error LNK2005: ___xc_z already defined in MSVCRT.lib(cinitexe.obj)
LIBC.lib(crt0init.obj) : error LNK2005: ___xc_a already defined in MSVCRT.lib(cinitexe.obj)
LIBC.lib(crt0init.obj) : error LNK2005: ___xi_z already defined in MSVCRT.lib(cinitexe.obj)
LIBC.lib(crt0init.obj) : error LNK2005: ___xi_a already defined in MSVCRT.lib(cinitexe.obj)
LIBC.lib(winxfltr.obj) : error LNK2005: __XcptFilter already defined in MSVCRT.lib(MSVCRT.dll)
LINK : warning LNK4098: defaultlib "MSVCRT" conflicts with use of other libs; use /NODEFAULTLIB:library
LINK : warning LNK4098: defaultlib "LIBC" conflicts with use of other libs; use /NODEFAULTLIB:library
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is known as multiple-C library syndrome. The cure is that you ensure that Fortran and C++ libraries on appropriate tabs of Project Settings are the same (e.g. "Single-threaded" for Release, "Single-threaded Debug" for Debug). In the special case of static library, it's better to ensure that the Fortran .lib does not contain hints to the linker about which run-time library to use -- check "Disable default library search rules" (/libdir:noauto) on Project/Settings/Fortran/Libraries/Other library options.
Jugoslav
Jugoslav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks. In fact, i do not have Fortran settings inside my C++ IDE. However, I copiled my fortran sourse using ifl /MD option and then everything seems to be working fine. Somehow, all of this works only in the release version. The debug vresion stills complains that it cannto find _DSLUC (first error) even ater I set the project/settigs to debug-Multithreaded.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Oh, sorry, I already forgot it was IFL -- it was CVF solution :">. Check out the documentation -- in CVF, the switch is /libdir:noauto, and in VC++ it's /Zi; don't know about IFL. /MD will work, but if you decide to change run-time library in C++, you will have to rebuild Fortran sources as well.
However, the two problems shouldn't be related. Are you sure you rebuilt everything properly? Perhaps you forgot to add the Fortran .lib to linker settings for Debug configuration in VC++ (oh I hate VS Project Settings dialog)?
Jugoslav
However, the two problems shouldn't be related. Are you sure you rebuilt everything properly? Perhaps you forgot to add the Fortran .lib to linker settings for Debug configuration in VC++ (oh I hate VS Project Settings dialog)?
Jugoslav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dude you are genious. That was the problem. I had to add the library in the project->settings. For now I'm happy and my digital baby is working fine. More later.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jugoslav is NO genius, he is GOD!
Tim
Tim

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page