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

Creating DLL. Do not want to link to a static LIB similar to MAC.

Syed_R_
Beginner
784 Views

I am creating a DLL that has some functions that are in a separate static library (.LIB file).

 In Linux and Mac, I can create the .so (shared object) without linking to the static library. Linux is straightforward. In Mac, I do the following:

libtool -dynamic -undefined suppress -flat_namespace -macosx_version_min 10.7 -o PluginSystem/Plugins/VerificationPlugin.fortran.so PluginSystem/Plugins/VerificationPlugin.fortran.o

This gives me a .so file without the need of the static library.

How can I do this in Windows. Is there a setting that can let me not link to the external procedures that are present in the static library? Please help!

0 Kudos
7 Replies
Steven_L_Intel1
Employee
784 Views

Windows doesn't allow you defer linking to a static library for references in a DLL.
 

0 Kudos
Syed_R_
Beginner
784 Views

Thanks Steve for the information that Windows doesn't allow to defer linking to a static library for references in a DLL.

Here is my problem now.

I have a static library called aStatic.lib that was created with Runtime library: Debug Multithreaded

I have a bDynamic.dll that was linked with aStatic.lib with Runtime library: Debug Multithreaded

I now want my test program to link with both aStatic.lib and bDynamic.dll. My test program is with Runtime library: Debug Multithreaded

The bDynamic.dll. is dynamically loaded and consumed with functions like LoadLibrary and GetProcAddress.

Everything looks fine except that I hit a HEAD error:  "Debug Assertion Failed" - dbgheap.c Line 1424, Expression _pFirstBlock==pHead

The above setup work perfectly fine in Linux and Mac with .so files (instead of dll as in Windows).

I don't know what setting in IFORT Visual Studio to change now. Please help!

0 Kudos
Steven_L_Intel1
Employee
784 Views

You need to change the runtime library in both the static library and DLL projects to "Multithreaded DLL" (Debug for the Debug configuration if you wish, non-debug for the Release configuration.) The way you have it, you have two copies of the run-time libraries that don't talk to each other, leading to errors such as this.

0 Kudos
Syed_R_
Beginner
784 Views

Thanks Steve. So I should have Multithreaded DLL set as Runtime library for all the THREE projects. Right? i.e. Static Library project, DLL project, and the test project.

0 Kudos
Steven_L_Intel1
Employee
784 Views

Yes.

0 Kudos
Syed_R_
Beginner
784 Views

OK, I am getting this error:

LIBCMT.lib(ieee87.obj) : error LNK2005: __clearfp already defined in MSVCRT.lib(MSVCR110.dll)

When I place MSVCRT.lib in the Ignore Library list, this error goes away. However, it seems that the "multiple copies of the run-time libraries that don't talk to each other" is still there. Any ideas?

 

0 Kudos
Steven_L_Intel1
Employee
784 Views

You need to recompile all the sources and make sure that the setting for the runtime library is the same in each. ieee87.obj is still referencing the static libraries.

0 Kudos
Reply