December 1, 2010

blex blex
Lab Rat
192 posts

[Solved] Linking with binary libraries compiled with other MSVC version

Page  
1

The Qt4 application is build in MSVC2005 Express edition. It uses third-party binary libraries compiled with MSVC2005 team edition.

When I try to run the application it fails with non-informative message. Using procmon I understand that the problem is in location of the MSVC runtime libraries for the third-party binary library.

Is it safe to link one application with different MSVC runtime libraries?
How to solve the problem with missing MSVC runtime?

WinXP x32 is used.

I understand that the question is not exactly Qt-related, but application and libraries are used Qt.

 Signature 

————————————

Oleksiy Balabay

16 replies

December 1, 2010

Franzk Franzk
Lab Rat
830 posts

Static or dynamic libraries?

 Signature 

“Horse sense is the thing a horse has which keeps it from betting on people.”—W.C. Fields

http://www.catb.org/~esr/faqs/smart-questions.html

December 1, 2010

blex blex
Lab Rat
192 posts

Third-party library is linked as dynamic.

 Signature 

————————————

Oleksiy Balabay

December 1, 2010

Franzk Franzk
Lab Rat
830 posts

If the required runtime libraries are installed I wouldn’t expect any issues. It could be that you only have an earlier version of the 2005 run-time libraries installed.

Actually for me it stays anybody’s guess how windows libraries are managed (and for my job I develop windows libraries ffs…).

 Signature 

“Horse sense is the thing a horse has which keeps it from betting on people.”—W.C. Fields

http://www.catb.org/~esr/faqs/smart-questions.html

December 1, 2010

blex blex
Lab Rat
192 posts
Franzk wrote:
If the required runtime libraries are installed I wouldn’t expect any issues.

Thanks, I will try to find the redistributable package that contains used libraries of correct version.

 Signature 

————————————

Oleksiy Balabay

December 1, 2010

Volker Volker
Ant Farmer
5428 posts

I don’t know if it really works if both runtimes are installed, but it would definitely scare me if I knew my app runs on two different C and C++ runtimes at the same time.

For Visual Studio 2005 there are actually to versions: the original VS2005 and VS2005 Service Pack 1 (SP1). Binaries built with SP1 don’t run with orignial VS2005 libs. I don’t know exactly if that is true for the other way round, too.

The easiest way to get around these issues would be to use the exactly the same compiler version that the libs/DLLs are built with (of course only if you happen to own the respective version…. which might be a problem).

December 1, 2010

blex blex
Lab Rat
192 posts

Thanks, Volker.

As far as I know the libs are different for MSVC2005 Express Edition and MSVC2005 Team Edition

 Signature 

————————————

Oleksiy Balabay

December 1, 2010

Volker Volker
Ant Farmer
5428 posts

From an ABI (Application Binary Interface) view this should not make any difference. It’s more a question of SP1 or not. I once got bitten by this when I used the precompiled libs that the Trolls provide; these were built with VS2005+SP1, I had no SP1 installed (and could not upgrade for some reason). I could not link my application against these DLLs and went off to compile Qt by hand, so that they depend on the very same libs and version my installation provided.

I know, all this is a big nightmare :-(

If you can grab the sources of the lib you use, it would be best to compile it yourself.

December 1, 2010

blex blex
Lab Rat
192 posts
Volker wrote:
If you can grab the sources of the lib you use, it would be best to compile it yourself.

Unfortunately, it’s impossible. Thank you for explanation.

 Signature 

————————————

Oleksiy Balabay

December 1, 2010

Volker Volker
Ant Farmer
5428 posts

No problem, you’re welcome. We’ve now ended with three virtual machines, one for VS2005 without SP1, one for VS2005+SP1 and one for VS2008 each. That’s only to separate from the different dependencies.

December 1, 2010

Denis Kormalev Denis Kormalev
Lab Rat
1654 posts

yes, Volker is right about SP1 and it can be a root of problem I think.

December 1, 2010

blex blex
Lab Rat
192 posts
Denis Kormalev wrote:
yes, Volker is right about SP1 and it can be a root of problem I think.

I am recompiling now and will report about result to compete the topic.

 Signature 

————————————

Oleksiy Balabay

December 2, 2010

blex blex
Lab Rat
192 posts

Yes, the SP1 was a root of the problem.

Thanks all for assistance.

 Signature 

————————————

Oleksiy Balabay

December 2, 2010

razvanpetru razvanpetru
Lab Rat
24 posts

Linking is safe (fails at build time), the painful part comes when you use the library and when deploying. Definitely not a recommended thing to do.

December 2, 2010

blex blex
Lab Rat
192 posts
razvanpetru wrote:
Linking is safe (fails at build time), the painful part comes when you use the library and when deploying. Definitely not a recommended thing to do.

When I install service pack then the used library is the same. Thank you for recommendation.

 Signature 

————————————

Oleksiy Balabay

December 2, 2010

Volker Volker
Ant Farmer
5428 posts

You must install both runtimes (MSVCRT, MSVCP) on the target machine. There are installers from Microsoft for that (vcredist exe or an MSI include); you must execute both .exe or include both MSI snippets.

Page  
1

  ‹‹ translator      The first image printed to PDF is invisible ››

You must log in to post a reply. Not a member yet? Register here!