2

I have installed MS VS Express 2013 on my office computer, and compiled a DLL with it. Now when my colleague is trying to use it, she gets an error about a missing MSVCR120.DLL. We have found MSVCR100.DLL on her PC. I know that we can get MSVCR120.DLL from Microsoft. However it will probably require admin rights, and only I have them in our team. I wonder if I can ask VS 2013 to compile the DLL so that it uses older version of redistributables? Or is installing the previous version of VS the only solution?

texnic
  • 3,959
  • 4
  • 42
  • 75
  • I'm fairly sure you can target the "110" DLLs, but I'm not so sure about the "100" DLLs. But you can always *copy* the DLL's into the install directory of your program. – MSalters May 08 '14 at 09:53
  • @MSalters: (1) Such copying requires admin rights. I am not writing a program, just creating a custom DLL which another program will then find in a special folder. We can access that folder w/o admin rights, but not the installation directory of the program. (2) Wouldn't such mixing cause a memory allocation problem described here: http://stackoverflow.com/a/19860574/674976? – texnic May 08 '14 at 10:02
  • Why can't you install and use VC++2010 Express to compile your DLL? – harper May 08 '14 at 12:24
  • @harper: I probably can, but I was wondering if there was an alternative. – texnic May 08 '14 at 12:39
  • 1
    @texnic by the way, your link is *the wrong version*. You need the *2013* redist. It is easy to confuse the version number 12 with the *name* Visual Studio 2013. – crashmstr May 08 '14 at 13:01
  • Also if this is about admin rights, how do they get software installed anyway? There should be a process to do so, so you should use it to get the required DLLs installed. – crashmstr May 08 '14 at 13:02
  • @crashmstr: Please read my comment to MSalters above. – texnic May 08 '14 at 13:03
  • Link to redistributables corrected in the question, thanks to @crashmstr for attention. – texnic May 08 '14 at 13:11
  • It is just another DLL you need to copy. Little reason to fret about it, best place for it is in the same directory as your DLL. Exactly which compiler version is used to build the EXE that uses your DLL is *not* a minor detail. The runtime errors that can be caused by your colleague having to use a different version are dastardly hard to debug. C++ has many sharp edges that can draw blood, the C++11 changes are especially troublesome. Always keep in mind that you are operating a hundred-horsepower chainsaw without a safety switch. – Hans Passant May 08 '14 at 14:38

2 Answers2

3

I found the solution — here: https://stackoverflow.com/a/1073772/674976. The distributable DLL can be statically linked to my DLL, thus removing the dependence. This is done in VS 2013 in Project Properties (Alt + F7) > Configuration Properties > C/C++ > Code Generation > Runtime Library, which should be set to Multi-threaded (/MT) from the default Multi-threaded DLL (/MD).

However, I wonder if by doing so I am actually still using redistributable DLLs of two versions and thus risk mixing the heaps and potentially causing memory allocation problems.

If someone suggests a better solution or a clear explanation why I should simply use Visual Studio 2010, I'll be happy to accept it is an answer.

Community
  • 1
  • 1
texnic
  • 3,959
  • 4
  • 42
  • 75
  • While this does solve the problem, just search for [2013 VCRedist](http://www.microsoft.com/en-us/download/details.aspx?id=40784) and voila: you have an installer for the DLLs needed. – crashmstr May 08 '14 at 12:58
  • @crashmstr: As I explained in my question, this is not a solution, since you need admin rights on the target computer to install redistributables. – texnic May 08 '14 at 13:00
  • Then how do they get any other software installed? Just use that process. Pretty simple. – crashmstr May 08 '14 at 13:03
  • @crashmstr: It is anything but simple. Any software should be first analysed (why we need it), then approved, then the process should be set up (takes months), tested, rolled out, and then they will get the right file. Me switching to VS 2010 takes what — one hour? But I wanted to use the latest tool, if possible. And this solution actually allows exactly that. – texnic May 08 '14 at 13:05
  • 1
    ...then how did you get VS 2013 installed? If you want to use 2013 but leave your team using 2010 and still work on projects together? *Don't*. – crashmstr May 08 '14 at 13:07
  • @crashmstr: I am the only one using Visual Studio in our team. I need to create a DLL for Zemax, which will then be used in Zemax by other team members. Zemax relies on the version 10 redistributables. – texnic May 08 '14 at 13:09
0

Visual Studio 2013 can build Visual Studio 2010 C++ projects. To do this, you need to also have Visual Studio 2010 installed, because VS2013 will actually call the VS2010 C++ compiler.

What I have done to accomplish this is to create the solution and all the projects in Visual Studio 2010 and make sure that they build and run correctly. Then open them in Visual Studio 2013 and make sure to NOT upgrade the projects to VS2013.

Now you can use the latest tool and still build the VS2010 dlls that you need.

Joel Rondeau
  • 7,486
  • 2
  • 42
  • 54