Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7956 Discussions

How to include libmmt.lib in a static library?

djungl
New Contributor I
1,646 Views

Hello,

I have the following setup with two Windows machines:

On Machine 1 I have the full Intel compiler toolchain. I create some object files using the Intel compiler. These object files require math functions from libmmt.lib Then I create a static library from the object files like so

 

 

link /out:tmp.lib file1.obj file2.obj
link /out:static-lib.lib tmp.lib libmmt.lib

 

 

That is, I first create a temporary static library with the object files and then combine that temporary library with libmmt.lib into a single static library.

Now I copy static-lib.lib to Machine 2. That machine only has the Microsoft compiler. When I try to link with static-lib.lib there then linking always fails with an error

 

 

LINK : fatal error LNK1104: cannot open file 'libmmt.lib'

 

 

How can I resolve this problem? How can I package libmmt.lib into my static library so that it no longer depends on libmmt.lib? If possible, I want to avoid copying libmmt.lib to Machine 2.

I found this thread which is kind of related but does not provide a solution to my problem.

0 Kudos
1 Solution
djungl
New Contributor I
1,567 Views

I think I solved the problem.

First of all, I found out that my object files contain this string:

defaultlib:"uuid.lib" -defaultlib:"uuid.lib" -defaultlib:"libmmt" -defaultlib:"LIBCMT" -defaultlib:"libirc" -defaultlib:"svml_dispmt" -defaultlib:"OLDNAMES" -defaultlib:"libdecimal"

I am not sure what that is but I strongly suspect that this causes the linker to attempt to link libmmt.lib when trying to link this object file.

After this, I tried to link using argument /nodefaultlib:libmmt. This made the error about libmmt.lib go away. However, now I was presented the same error but for the libirc library:

LINK : fatal error LNK1104: cannot open file 'libirc.lib'

So I added /nodefaultlib:libirc to my link line as well.

 

Continuing with this I finally ended up with this approach:

On the machine that has the Intel libraries installed, create the static library like so:

lib /out:tmp.lib file1.obj file2.obj
lib /out:static-lib.lib tmp.lib libmmt.lib libirc.lib svml_dispmt.lib

On the machine that does not have the Intel libraries installed I now do

link /out:binary.exe /nodefaultlib:libmmt /nodefaultlib:libirc /nodefaultlib:svml_dispmt /nodefaultlib:libdecimal main.obj static-lib.lib

where main.obj is an object file that was compiled on the machine without Intel libraries and uses functions from static-lib.

This seems to work for now.

View solution in original post

0 Kudos
4 Replies
VidyalathaB_Intel
Moderator
1,611 Views

Hi,

 

Thanks for reaching out to us.

>> When I try to link with static-lib.lib

Could you please give us more insights about the issue as we are unable to reproduce it and if possible could you please tell us with what you are linking it with and also the steps you have followed.

>> I create some object files using the Intel compiler

Also please let us know which intel compiler you are using.

Meanwhile refer this link for further information which might help you. https://software.intel.com/content/www/us/en/develop/documentation/cpp-compiler-developer-guide-and-reference/top/compiler-reference/libraries/redistributing-libraries-when-deploying-applications.html

Thanks & Regards,

Vidya. 

 

0 Kudos
djungl
New Contributor I
1,568 Views

I think I solved the problem.

First of all, I found out that my object files contain this string:

defaultlib:"uuid.lib" -defaultlib:"uuid.lib" -defaultlib:"libmmt" -defaultlib:"LIBCMT" -defaultlib:"libirc" -defaultlib:"svml_dispmt" -defaultlib:"OLDNAMES" -defaultlib:"libdecimal"

I am not sure what that is but I strongly suspect that this causes the linker to attempt to link libmmt.lib when trying to link this object file.

After this, I tried to link using argument /nodefaultlib:libmmt. This made the error about libmmt.lib go away. However, now I was presented the same error but for the libirc library:

LINK : fatal error LNK1104: cannot open file 'libirc.lib'

So I added /nodefaultlib:libirc to my link line as well.

 

Continuing with this I finally ended up with this approach:

On the machine that has the Intel libraries installed, create the static library like so:

lib /out:tmp.lib file1.obj file2.obj
lib /out:static-lib.lib tmp.lib libmmt.lib libirc.lib svml_dispmt.lib

On the machine that does not have the Intel libraries installed I now do

link /out:binary.exe /nodefaultlib:libmmt /nodefaultlib:libirc /nodefaultlib:svml_dispmt /nodefaultlib:libdecimal main.obj static-lib.lib

where main.obj is an object file that was compiled on the machine without Intel libraries and uses functions from static-lib.

This seems to work for now.

0 Kudos
djungl
New Contributor I
1,567 Views

I cannot seem to edit my post anymore. Unfortunately, I made a mistake. The commands to create the static library should be "lib", not "link".

0 Kudos
VidyalathaB_Intel
Moderator
1,549 Views

Hi,

Glad to know that your issue is resolved.

If you need any additional information, please submit a new question as this thread will no longer be monitored.

Any further interaction in this thread will be considered community only.

Thanks & Regards,

Vidya.


0 Kudos
Reply