Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29277 Discussions

3rd-party Static Libraries & MCLS

Jugoslav_Dujic
Valued Contributor II
743 Views
I'm developing a static library (xft.lib) that will be used by other people (i.e. it will be 3rd-party for them). However, I don't see a way how to avoid Multiple C Library Syndrome (MCLS) in general.

Let's consider a typical Debug configuration. In project settings for XFT.lib, "Debug single-threaded" is specified for both "Fortran" and "C++". If (and only if) "Debug single-threaded" is specified at both places in the calling application (app.exe), everything is OK. Otherwise, MCLS strikes, i.e. a linker warning is issued about conflicting libraries. Obviously, it would be rude to force the user to specify the same set of libraries as the one xft.lib was linked against.

However, I didn't find a sensible workaround. One way is to provide xftD.lib, xftMTD.lib, ...xftMTdll.lib but this is quite tedious. Yet, I didn't find a way to tell the compiler not to use any class of RTLs when building xft.lib, but to resolve the references when building the app.exe (/nodefaultlib on "library" tab didn't help). [Does the last sentence make sense?].

I have a feeling that I'm missing something trivial, but I can't figure out what it is.

Jugoslav
0 Kudos
4 Replies
Steven_L_Intel1
Employee
743 Views
I'm not at all astonished the solution did not occur to you. It's far from obvious.

What you want is to prevent the compiler from inserting into the object module the linker commands to pull in specific libraries. From the command line, that's libdir:nouser - from the IDE, Fortran..Libraries..Disable OBJCOMMENT LIB directives.

You're then dependent on the user's program pulling in the correct libraries.

Steve
0 Kudos
Jugoslav_Dujic
Valued Contributor II
743 Views
Thanks Steve, but /libdir:nouser doesn't appear to do the trick. You did put me on the right track, though, because /libdir:noauto ("Disable default library search rules") does? Documents on /libdir (although a bit vague) seem to indicate that /libdir:noauto is the winner indeed. [Actually, I do have some !DEC$OBJCOMMENTs in the code, for some exotic Windows libraries, so it's better still].

I feel that the AppWizard should check on this switch by default -- situations when one does want to specify the set of RTLs when building a static lib appear rather exotic to me.

Jugoslav
0 Kudos
Steven_L_Intel1
Employee
743 Views
Sorry - /libdir:noauto is what I should have written...

Interesting point regarding the default. I'll bring it up for discussion here.

Steve
0 Kudos
Jugoslav_Dujic
Valued Contributor II
743 Views
Just FYI, VC++'s "Win32 Library" wizard does it -- it adds /Zl to compiler settings.
0 Kudos
Reply