How to compile zlib into a DLL on Visual Studio 2017? - c

I have a hard time trying to do something I think is really simple (I must not be the first one to want to do that). I use Visual Studio 2017 on Windows 7 to do some C code, and I need inflate/deflate for zip.
I search a little, and I found zlib. It seem to be exactly what I search: free, cool copyright, no patent and extensively used and tested in other project.
So, I start to download the latest version (zip of 1.2.11) and here I go, trying to "simply" get the DLL.
However, the documentation state that in order to compile "zlib1.dll", I have to use "./contrib/vstudio/vc..", with ".." the right Visual Studio. But I have Visual Studio 2017 and there are only "vc9" to "vc14", "vc14" being Visual Studio 2015.
The doc say that I have to use Microsoft Visual C++ 2015, and indeed, when I force open with vs2017, I have integrity error.
So I try to install MVC++ 2015, but then it say that I can't install it because I already have something (VS2017) installed.
Is there really no way to achieve something so basic, or there is knowledge that I don't know?

Open source projects can be a challenge to build as their support tends to lag well behind the latest versions of Visual Studio. This is one reason why Visual Studio now supports cmake directly.
That said, the easiest way to build zlib for Windows is just use a NuGet package. I personally use zlib-msvc14-x86 or zlib-msvc14-x64 which are binary compatible with VS 2015 Update 3, VS 2017, and VS 2019. They also provide a static library instead of a DLL.

Related

How to program kernel drivers for windows without visual studio?

Everytime I see a driver tutorial I see they use visual studio, I was just wondering if it is absolutely required to install it in order to develop windows drivers?
Say for example I would like to compile the following driver: (source)
NTSTATUS DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
{
DbgPrint("Hello World\n");
return STATUS_SUCCESS;
}
How would I be able to compile/link it without visual studio? I have searched all over the place.
The linked tutorials are based on older WDK builds. You can get the old WDK and follow the tutorial, but I don't really recommend it.
Recently, the common way to develop Windows drivers is to use Visual Studio, but there is also a similar approach to the tutorial, which is developed from the command line environment.
https://learn.microsoft.com/en-us/windows-hardware/drivers/develop/using-the-enterprise-wdk
Of course, you don't have to install Visual Studio as using EWDK.
If you would like to use a different IDE then you must use the Enterprise Windows Driver Kit (EWDK) https://learn.microsoft.com/en-us/windows-hardware/drivers/develop/using-the-enterprise-wdk
After downloading and unzipping the archive you will need to launch LaunchBuildEnv.cmd and then run MsBuild.
Example:
Msbuild my_driver_project.vcxproj /p:configuration=debug /p:platform=x64
This assumes that you will write your own vcxproj file. Details about the file format here: https://learn.microsoft.com/en-us/cpp/build/reference/vcxproj-file-structure?view=vs-2019 and you could look at some driver samples from Microsoft here: https://github.com/microsoft/Windows-driver-samples
If you are just starting out with Windows Drivers I would say that using Visual Studio and WDK is a good idea because you can concentrate more on core Driver Development concepts and after you have something working you can write your own vcxproj file and use the eWDK. Having some examples of vcxproj files is useful.
If you do go down the Visual Studio route you can use Visual Studio Community edition which is free for non-commercial use.
It is important to install Visual Studio prior to WDK because the WDK is essentially a plugin to Visual Studio.
Additional instructions and download links for Visual Studio and WDK https://learn.microsoft.com/en-us/windows-hardware/drivers/download-the-wdk

How to install Visual C coding tools to Visual Studio 2015?

I have an older Visual Studio solution with source code of Quake III Arena (a first person shooter game from 1999). It has also source codes of number of useful tools, which need to be edited in order to work with a new game made from Quake 3 engine. All of this code was written in C and in order to work with this older solution (may switch Visual Studio to compatibility mode), I need to first install Visual C tools into my Visual Studio 2015 Community edition copy.
But Google doesn't help much. It still wants me to download Visual C++, but that's something I already have. Visual C is missing and without it the older solution won't work. Is it possible? I want to test making own modification of the game, creating whole new game out of the engine and modifying the tools needed to create assets for the new game, add them new game as an option. Should I download older Visual Studio instead if there is no Visual C for new VS? Where do I download Visual Studio 2008, the one in which the source code was packed?

Trying to build Mozilla got this error when trying to open start-shell-msvc2015

I am trying to build Mozilla on Windows 7 64bit
I tried to run this start-shell-msvc2015.bat but got this error.
MozillaBuild Install Directory: C:\mozilla-build\
Visual C++ 2015 Directory: C:\Program Files (x86)\Microsoft Visual Studio 14.0\V
C\
Windows SDK Directory: C:\Program Files (x86)\Windows Kits\8.1\
Unable to call a suitable vcvars script. Exiting.
Press any key to continue . . .
I did everything according to their instructions
When in doubt, search Google for the error message. From the first result:
Hallvord R. M. Steen:
To anybody else who might have this problem: it's caused by choices made during installation, and the installer options were somewhat confusing. I don't remember the exact details, but I think the "Default" installation no longer gives you the required scripts - the "Default vs custom" section on https://msdn.microsoft.com/en-us/library/e2h7fzkw%28v=vs.140%29.aspx seems to confirm that you need to choose "Custom" during install and enable Visual C++ tools specifically.
Andrew Overholt: You're right, Hallvord. I went back to my VS2015 installation .exe download, clicked "Modify [the existing installation]" and picked "Common Tools for Visual C++ 2015" under "Programming Languages" > "Visual C++".
Also you'll need at least update 3 if you're using the VS2015 Community Edition. From that Mozilla dev docs page:
Once you’re up to date, download and install Visual Studio Community 2015 Update 3 from Microsoft. If you have an earlier version of Visual Studio, you'll need to upgrade; Firefox relies on C++ features that aren't supported in older versions of Visual Studio. Do not accept the default configuration. Instead, select **Programming Languages > Visual C++ > Common Tools for Visual C++ 2015.*
See also this question on Super User.
Furthermore, the MDN docs actually were updated with this info after that report, and indeed the current build instructions contain, in bold:
Be sure to install the "Common Tools for Visual C++ 2015", which requires a customized installation in Visual Studio 2015.
In the prerequisites section.
Also you'll need at least update 3 if you're using the VS2015 Community Edition. From that Mozilla dev docs page:
Once you’re up to date, download and install Visual Studio Community 2015 Update 3 from Microsoft. If you have an earlier version of Visual Studio, you'll need to upgrade; Firefox relies on C++ features that aren't supported in older versions of Visual Studio. Do not accept the default configuration. Instead, select Programming Languages > Visual C++ > Common Tools for Visual C++ 2015.

Way around deploying prerequisites for Winform code

Currently I have a 60MB assembly which needs a 100 MB of prerequisites to be installed. For example Visual C++ 2005 for Crystal reports, Visual studio Tools for Office 2010 , Visual C++ 2010 redistributable and finally .NET framework.
Is there a way through which I don't need to deploy these prerequisites, inturn saving time and space?
May be there is a way to extract and include only those parts within these prerequisites which are needed.
With certain exceptions, MSFT generally doesn't support this. Using high level languages, frameworks, APIs and such come with a cost. You don't get all that for free... it has to be deployed.
That said, you can make choices to make it more manageable. You can target .NET 3.0+ and eliminate Windows XP and the .NET Framework suddenly doesn't need to be distributed.
You can also choose not to redistribute them and instead have your installer simply error out and tell the user to go install it.
It's one of those "it is what it is" problems.
I believe there are merge modules for CR for VC++ 2005 that you can include in your MSI build, but that redist isn't huge anyway. I also believe you don't need to install Visual Studio Tools for Office 2010 either, you need the Visual Studio Tools for Office 2010 Runtime Redistributable, not the same thing. The VC++ 2010 redist isn't that huge either, but again there are merge modules you could include in your MSI. I also suspect that you don't need the entire NET Framework, just the Client Profile redist.

Using old code on new version of Visual Studio

I have a project which was started from 90s in C/C++. Therefore, it contains many old coding styles such as K&R-style function declaration, obsolete function, ...
The project works fine in Visual Studio 2008, but now I want to use it in the new version of Visual Studio (specifically VS 2010) because we have other projects in Visual Studio 2010/2012. I don't want to have too many versions of Visual Studio on my machine.
When I try to compile the old project, Visual Studio throws too many errors. I can fix all of them but I am scared to edit the source code and I want other people to be able to pen it in the old version of VS too. I want the project to remain backwards compatible with VS.
My question is how to use the old code in Visual Studio 2010/2012 without changing the code. Or if necessary how do I just fix a few lines of code, but make sure it won't cause an error if someone else opens that code in the older version of VS. Is there a way to tell newer Visual Studio versions to use older compiler flags or something like that?
Best option is IMHO to bite the bullet and install VS 2008 and VS 2012 both on your machine, and then use the V90 platform toolset within VS 2012 (that means, you can edit and debug in VS 2012, but VS will use the old VS 2008 compiler and debugger under the hood).
What you don't get that way, however, is backward compatibility concerning project files. VS 2012 is only backwards comptible to VS 2010, but not to VS 2008. If you need that really, you either have to maintain two versions of your project files (one for VS 2012 and one for VS 2008), or you must stick to VS 2008 as an IDE.

Resources