Static Link Question (Windows 7)

Static Link Question (Windows 7)

I am correctly linking a static library that uses IPP - call it Lib A.  It runs fine as well but I must have done something incorrect.  When I try to incorporate Lib A into a statically linked Lib B that uses Lib A, VS 2012 insists that I provide the path to the IPP libraries when linking Lib B.  I am trying to build and share a static library that will not require developers to have IPP installed.  I have #include <ipp_u8.h> and I have downloaded the special version of IPP - version 7.1.1.119.  The Lib A size is almost 4 Mb so I am confident that I have included the portions of IPP that I want to use but linking Lib A into Lib B leaves all the IPP functions unresolved without the path to IPP.  Am I not allowed to redistribute a static library that incorporates IPP functionality?  I expect others to put in my static Lib A into their library code as well as executables.  Or must the Lib A only be incorporated into an executable?  I could see that Intel might not want me just wrapping IPP functions into a static library that I could share for developers (distribution of IPP is royalty-free.)  I work for Intel and would like to redistribute a library for developers.

Bob Davies

3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

>>...I want to use but linking Lib A into Lib B leaves all the IPP functions unresolved without the path to IPP...

Paths to some libraries used by the linker are always needed. In reality it could be done in two different ways:

1. In project settings of a VS.

or

2. Using #pragma comment ( lib, "...path to a library..." ) directive in a header or source file.

Hi Bob,

Cannot say anything about redistribution, it's not my area.

But regarding libraries... What is static library in Windows/Linux and other OSes? It is just a set of object modules. You cannot "build" the library. Usually the term "build" is applied to executable binary file (.exe) or dynamic library (.dll or .so on Linux). The static library is created by almost copying of several object files into a single file. There is some structure inside .lib/.a file of course, but it is used to separate one object module from another.

So, if you create a static library file from modules, which have calls to, for example, IPP functions, you will not have the IPP functions themselves (their object codes) inside your library. You will simply get a set of your object files with external references to some global names. The linkage between external references from several static libraries (inluding IPP static libraries, because they are the same static libs) is resolved by linker.

If you want to create a library which will have your modules and modules from IPP libs, you will need to extract object modules from IPP libs, using "lib" tool on Windows, or "ar" on Linux, manually and, then, put them into your library, using the same lib/ar tools. From the legal point of view, I think it's possible, but nevertheless please check against license agreement. Here I speak from technical point of view.

This must be done for all(!) object modules, including indirectly dependent (some IPP functions can use other IPP functions, which are not directly called from your modules).

Regards,
Sergey 

Regards,
Sergey

Leave a Comment

Please sign in to add a comment. Not a member? Join today