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

Static link to libguide40.lib

dhna9ac
Beginner
1,084 Views

I'm creating some Fortran dlls and want them to be independent. I was able to remove the dependency on libcoremd.dll and libmmd.dll by setting "Multithread" in "Runtime Library" option. However, I couldn't get rid of thedependency on libguide40.dll using this setting. I tried to link libguide40 statically by setting"Linker/General/Additional Library Directories/libguide40.lib path"and "Linker/Input/Additional Dependencies/libguide40.lib". Unfortunately, I still got unresolved externals (error LNK2019: unresolved external symbol ___kmpc_global_thread_num referenced in ...) when compiling the dll.Was I missing something here? Thanks. Dinh

0 Kudos
8 Replies
Steven_L_Intel1
Employee
1,084 Views
The correct library now is libiomp5mt.lib. However, you can instead (assuming you are using a reasonably current version of the compiler) add /Qopenmp-link:static to Additional Options.
0 Kudos
dhna9ac
Beginner
1,084 Views
Thanks, Steve. First, I tried to use libiomp5mt.lib and here's my Fortran/Command Line/All Options:
/Qparallel /heap-arrays0 /fpp /recursive /reentrancy:threaded
/warn:declarations /warn:unused /real_size:64 /module:"Release\" /object:"Release\" /libs:static /threads /c


... and here's my Linker/Command Line/All Options:
/OUT:"C:\MyDlls\SpProp.dll" /NOLOGO /MANIFEST /MANIFESTFILE:"C:\MyDlls\SpProp.dll.intermediate.manifest"
/SUBSYSTEM:WINDOWS /IMPLIB:"C:\MyDlls\SpProp.lib" /DLL libiomp5md.lib

The compiler successfully created the SpProp.dll. However, when I used Dependency Walker to check it, I saw the LIBIOMP5MD.DLL listed as its dependency. Then I tried /Qopenmp-link:static as you suggested, I got this warning "warning #10006: ignoring unknown option 'Qopenmp-link:static'". It didn't seem my compiler supporting this option. I'm using Intel Fortran 11.1.067. It's strange since I did see this option listed in the User and Reference Guides. I also saw that performing static link to the OpenMP libraries is not recommended. Please help. Thanks. Dinh

0 Kudos
Lorri_M_Intel
Employee
1,084 Views
Please make sure you actually spelled the command correctly.

I just tried it with an 11.1.067 installation, and it was accepted.

And, yes, finally, it is true that it is not recommended that the OpenMP libraries be linked statically. As it was described to me, there is the *potential* for threads not to be able to share essential data.

Are you guaranteed to have problems? No.
That's why it is just "not recommended" instead of "not allowed".

-- Lorri
0 Kudos
Steven_L_Intel1
Employee
1,084 Views
Your link command explicitly references libiomp5md.lib, which brings in the DLL form. I don't see that you added /Qopenmp-link:static. Note that this is a compiler option, not a linker option.
0 Kudos
dhna9ac
Beginner
1,084 Views

I don't get it. I have two machines with the Intel Fortran compiler. One has both 11.1.066 and 11.1.067, and the other has only 11.1.067. The onewith twoversions didn't recognized the /Qopenmp-static:link option. The one with only 11.0.067 did recognize the option. However, the dependency of the the Debug version and Release version of the dll created on this machine (only 11.0.067)are different. Using Dependency Walker, I can see that theDebug version didn't need Intel Fortran library but the Release version still needed libguide40.dll.
I tested these dlls (using static linking) and they didn't seem to produce the correct results. Therefore, I have to stick with dynamic linking. Thank you all for your help! Dinh

0 Kudos
Steven_L_Intel1
Employee
1,084 Views
We did not release a 11.1.066. /Qopenmp-link was added in 11.0. Can you show the output of a compile that shows the option being rejected and includes the version output (default from the command line unless you use /nologo), I'd be interested in seeing it.
0 Kudos
dhna9ac
Beginner
1,084 Views

You're right. I mistyped the version. It should be 11.0.066. FYI, I have both 11.0.066 and 11.1.067 and both have 32-bit and 64-bit versions installed.

+ Output from 11.0.66:

1>------ Rebuild All started: Project: SpProp, Configuration: Debug Win32 ------

1>Deleting intermediate files and output files for project 'SpProp', configuration 'Debug|Win32'.

1>Compiling with Intel Fortran 11.0.066 [IA-32]...


... a long list of files ...

1>Compiling manifest to resources...

1>Microsoft Windows Resource Compiler Version 6.1.6723.1

1>Copyright (C) Microsoft Corporation. All rights reserved.

1>Linking...

1>Link: warning #10006: ignoring unknown option '/Qopenmp-link:static'

1>LINK : C:\AstroStds\V7_beta1_PostRelease\src\\DriverExamples\lib_Win32\SpProp.dll not found or not built by the last incremental link; performing full link

1> Creating library C:\AstroStds\V7_beta1_PostRelease\src\\DriverExamples\lib_Win32\SpProp.lib and object C:\AstroStds\V7_beta1_PostRelease\src\\DriverExamples\lib_Win32\SpProp.exp

1>Embedding manifest...

1>Performing Post-Build Event...

1>1 file(s) copied.

1>

1>Build log written to "file://C:\AstroStds\V7_beta1_PostRelease\src\FortranDlls\Projects\SpProp\Debug\BuildLog.htm"

1>SpProp - 0 error(s), 2 warning(s)


+ Output from 11.1.067:

========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========

1>------ Rebuild All started: Project: SpProp, Configuration: Debug Win32 ------

1>Deleting intermediate files and output files for project 'SpProp', configuration 'Debug|Win32'.

1>Compiling with Intel Visual Fortran 11.1.067 [IA-32]...

... a long list of files here ...

1>Compiling manifest to resources...

1>Microsoft Windows Resource Compiler Version 6.1.6723.1

1>Copyright (C) Microsoft Corporation. All rights reserved.

1>Linking...

1>Link: warning #10006: ignoring unknown option '/Qopenmp-link:static'

1>LINK : C:\AstroStds\V7_beta1_PostRelease\src\\DriverExamples\lib_Win32\SpProp.dll not found or not built by the last incremental link; performing full link

1> Creating library C:\AstroStds\V7_beta1_PostRelease\src\\DriverExamples\lib_Win32\SpProp.lib and object C:\AstroStds\V7_beta1_PostRelease\src\\DriverExamples\lib_Win32\SpProp.exp

1>Embedding manifest...

1>Performing Post-Build Event...

1>1 file(s) copied.

1>

1>Build log written to "file://C:\AstroStds\V7_beta1_PostRelease\src\FortranDlls\Projects\SpProp\Debug\BuildLog.htm"

1>SpProp - 0 error(s), 2 warning(s)

========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========

I don't use the command line version but I think the output from VS 2008 also gives the information you need. Thanks!

0 Kudos
Steven_L_Intel1
Employee
1,084 Views
Ok - looks as if this option was added in 11.1, not 11.0 as I thought.
0 Kudos
Reply