-1

I've asked a question similar to the topic a few days ago yet I've still failing to find a solution to this problem

I've built some software with C++, on a windows 7 x86 pc, using Visual c++ 2013, and I'm literally failing every way to redistribute my software... I've tried redistributing it on three different pc's

  • a pc running windows 10 x64
  • a pc running windows 7 x64
  • a pc running windows 7 x86

And when trying to run the software on the targer computer I'm always ending up with the same error: missing msvcp120.dll or msvcr120.dll

I've tried installing visual c++ redistributing on all target computers, Didn't help as well, also tried manually adding the missing dll's into the target computers system files and and yet failed to solve my problem it only created a new error

"the application was unable to start correctly (0x00007b)"

I honestly have no idea how to solve this... I'd love it if someome here may come up with a solution to this problem.

Also if someone here who already has experience in this matter could give me a few tips about redistributing a program written with Visual C++, that would be great

Thanks in advance and best regards, Itay.

DrPrItay
  • 793
  • 6
  • 20
  • 1
    [related](http://stackoverflow.com/questions/24726910/exe-gives-error-msvcp120-dll-is-missing-for-win7x64) – Zereges Apr 30 '16 at 18:46
  • You are copying the wrong files. Surely because you copied them from c:\windows\system32\ instead of c:\windows\syswow64. Just [run this](https://www.microsoft.com/en-us/download/details.aspx?id=40784) – Hans Passant Apr 30 '16 at 18:46
  • as I already stated, "I've tried installing visual c++ redistributing" and It did nothing..., Also what do you mean by you copied them from the wrong directory? @HansPassant – DrPrItay Apr 30 '16 at 18:51

1 Answers1

1

You can build your application with a statically linked runtime instead of dynamically linked runtime (see here: https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx), that way there's no need for these dlls.

Ton Plooij
  • 2,583
  • 12
  • 15
  • Ahhh, sorry for my lack of understanding but I have no idea how the guide you've linked me with is helpful... could you please be more specific?, thanks anyways :) – DrPrItay Apr 30 '16 at 19:01
  • 1
    The msvcp120.dll and msvcrt120.dll are linked to when you use the dynamic version of the runtime library. By default this is enabled. You can change this so your application will statically link to the runtime library. It will then include this runtime code in your application and does then not require you to distribute these dlls along with your application. Go to the project properties (right mouse click on project), select C/C++ code generation. For Runtime library, choose /MT or /MTd (without the dll). – Ton Plooij Apr 30 '16 at 19:20
  • Ahhh okay, but shouldn't I be adding the dll's I want to link? – DrPrItay Apr 30 '16 at 19:50
  • No, in the same way that you don't specify the runtime dlls themselves you don't need to specify the static version either. – Ton Plooij Apr 30 '16 at 19:53
  • This actually solved my problem, thank you very much... could you please explain to me what happened behind the scenes by doing it, what dll's did vs link?, and what does it mean "Runtime dlls", shouldn't the program be dependant only by it's code which is processor compatible, and to the OS which in all three cases should be compatible ( all target pc's were Windows 7+ ) – DrPrItay Apr 30 '16 at 19:56
  • Quite probably the wrong solution. Wouldn't it be better for the asker to learn about dependency and runtime distribution? Instead of trying stuff at random and then giving up before reading the docs. – David Heffernan Apr 30 '16 at 20:04
  • In a nutshell (and omitting a lot of details), the compiler needs to add some basic supporting code, e.g this is also the code that calls your main() function. This code is called the runtime library and it must be 'added' to your application to make it run. There are two ways to add this code, by adding a dll (dynamic linking) or by adding it through a static object file. Both variant must be linked to your application. The static version is embedded in your executable while the dynamic version requires a separate dll. Both options have pros and cons. – Ton Plooij Apr 30 '16 at 20:08