0

I have already looked at these 2 links from SF but they did not help me:

https://stackoverflow.com/questions/21591649/c-dll-providing-backward-and-forward-compatibility-for-callers

.lib and .dll Backward Compatibility

I have a C++ project and it is NOT based on CLR. The output is a DLL file. Right now i am on Windows 8 and using Visual Studio 2013 to build the project. The output DLL is working fine on Windows 8. But when i put the same output DLL in window 7 then i get error like "Missing DLL MSVCR120.DLL" i tried copying the missing DLL into System32 folder in Windows 7 and DLL missing error goes away but my DLL still does not work. It is only when i build the source in Visual studio 2010 on Windows 7 and then use its output DLL it works fine. On Windows 7, C++ redistributable runtime 2010 is installed. I also tried installing other versions of C++ runtimes but no success on Win 7.

Can i not use only one development machine and one visual studio to create one (or even multiple) C++ DLL which will work in most windows Versions like Vista, 7, 8, Server 2008 etc? Right now i have to build source code on each different OS with its own VS.

PS: The project is a Windows Credential Provider implementation.

2 Answers 2

0

You would normally need to install the VS2013 redistributable on all machines that the DLL is used.

An alternative would be to build your project to link with static runtime libraries, but the resulting executable would be larger in size; more details in this SO answer.

0

There can be a few reasons things don't work as expected

  1. You're project's target might be Windows 8 see - Using the Windows Headers. Basically if the dll is compiled for Windows 8 some new functionality of Windows 8 is unlocked, but this means that that previous versions of Windows is not supported.
  2. C++ Dlls is not ABI compatible across compilers, so depending on how the DLL is implemented, and how the compiler differs, it might or might not work. What I mean is when the application using the DLL is compiled in VC 2010 and the DLL is compiled in VC2013, the VS2010 application might not be able to load the VC2010 dll. See HowTo: Export C++ classes from a DLL alternatively you can do a full COM dll.
  3. You're Dll is depending on some other DLL that is not present, or the correct version is not present (i.e a new function was added to the dll, that you use, but the version of the dll on the system doesn't contain that function). Open the DLL with Dependency Walker on the machine you have trouble with, to show missing DLLs.
  4. Related to point 3. Install vcredist 2013 on the system that doesn't load the DLL, also if the DLL is 64 bit you would need 64 bit vcredist, or if the dll is 32 bit you would need 32 bit vcredist.
  5. A 64 bit application cannot load a 32 bit dll and vice versa.

I don't have enough reputation to post more than two links so search for Dependency Walker

2
  • How to change project target windows? A major problem is that the source code build in VS2013 is not successfully built in VS2010 and i get an error that on compilation "Error 4 error C2784: 'std::_Array_const_iterator<_Ty,_Size> std::operator +(_Array_const_iterator<_Ty,_Size>::difference_type,std::_Array_const_iterator<_Ty,_Size>)' : could not deduce template argument for 'std::_Array_const_iterator<_Ty,_Size>' from 'const char [2]'" Aug 5, 2014 at 9:00
  • @user2918703 I don't have enough information to help on that, could be that you use C++11 features. How about compiling the DLL and application on VS2013.
    – Badger
    Aug 5, 2014 at 10:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.