Compile C++ Code without a dependency on MSVCR80.dll  
Author Message
hallem





PostPosted: Visual C++ General, Compile C++ Code without a dependency on MSVCR80.dll Top

I'm trying to write a C++ application that can run command-line without any help from Microsoft. Meaning no .Net installed at all and no Visual Studio installed at all and without dependencies on the Microsoft Visual C Runtime Libraries. The application that I wrote doesn't use anything outside of standard C++ so it shouldn't require anything and it compiles on Unix AS IS. Any help would be appreciated.



Visual C++5  
 
 
Chuck the Code Monkey





PostPosted: Visual C++ General, Compile C++ Code without a dependency on MSVCR80.dll Top

'As Is' is a bit misleading. The dependency on MSVCR80.dll is the Unix equivilent of being dependant on libc.so.*. The only difference is that in the Unix world everybody already has a libc installed, where in MS world, the C runtimes are not included and need to be installed. You should be able to avoid this dependancy by enabling static linking instead of dynamic linking (in Unix use libc.a instead of libc.so).

In the C++ Project Property page, under Configuration Properties -> C/C++ -> Code Generation Change the Runtime Library option to wither Multi-threaded or Multi-threaded Debug instead of the DLL versions.

Note that this will drastically increase the size fo your executable since all the core C and C++ library functions will be compiled into the executeable.



 
 
hallem





PostPosted: Visual C++ General, Compile C++ Code without a dependency on MSVCR80.dll Top

Nice suggestion but tried that origionally and didn't work. Even when that is done the program still crashes looking for the MSVCR80.DLL file upon command line execution.
 
 
Ben Anderson MSFT





PostPosted: Visual C++ General, Compile C++ Code without a dependency on MSVCR80.dll Top

Changing to use the /MT or /MTd as described above will in fact remove your dependency on MSVCR80.dll.  However, this is not a recommended way of distributing your application because as stated, it will grow your file size and you will not receive security updates as you would by using the dll.  You can still distribute your app with a local copy of the dll which will be overridden by any security updates on the system in Windows Side by Side and not have to create an installer which includes the side-by-side msms to distribute your app as described in the MSDN distribution docs here:

http://msdn2.microsoft.com/en-us/library/ms235316(VS.80).aspx

 

An "app-local" or "private assembly" distribution method is what I believe you are looking for where you include the dll in your application directory.  However, the recommended method is to create a setup project and include the CRT msms in the project which will install the CRT for you to Windows Side-by-Side. 



 
 
hallem





PostPosted: Visual C++ General, Compile C++ Code without a dependency on MSVCR80.dll Top

I understand what you're saying but I'm confused about why when I use the /MT or /MTd options that the dependency is still there. I've compiled my application using these options and it still looks for the DLL. While on other projects it does not. What is happening