Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to avoid msvcr100.dll dependency when manipulating files?

I am writing a custom installer launcher in C which opens, reads and writes files. I use fopen() to open the files. This works perfectly on Linux and the binary does not depend on libstdc++.so but on Windows in Visual Studio 2010 I get a dependency on MSVCR100.DLL. If I add the /NODEFAULTLIB flag the linker fails.

I need this program to be free of the MSVCR100.DLL dependency since it launches an installer which at a later stage installs the VC++ 2010 Redistributable and at the time of the launch it is not sure if the host machine has this library.

How can I manipulate files in VS without MSVCR100.DLL?

like image 792
RegedUser00x Avatar asked Dec 02 '25 13:12

RegedUser00x


2 Answers

You get the dependency to msvcr100.dll (and probably msvcp100.dll) because your project settings define this. You should use static linking instead of dynamic linking of the runtime library.

Change your C/C++ code generation settings: Runtime Library. Select an option without DLL.

like image 177
harper Avatar answered Dec 04 '25 05:12

harper


Alternatively, if you can change your code a bit, you can use the Win32 API (CreateFile, ReadFile...). This will link to kernel32.dll, which is always available.

like image 20
ElderBug Avatar answered Dec 04 '25 07:12

ElderBug



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!