Does VS2015 automatically include windows SDK header files but not in VS2017? - c++

I have a C++ library originally developed in VS2015 which uses SOCKET from Winsock2 inside Windows SDK 8.1. The solution file is generated from a cmake file, and it builds perfectly fine.
I use the same cmake file to create the solution again in VS2017. However, I can not compile it unless I add #include <WinSock2.h> at the file where SOCKET is being used. It looks like it's not picking up the definition of SOCKET unless I explicitly include the WinSock2.h file. And I don't need to do that in VS2015.
I checked the project properties and they look the same and are both using Windows SDK 8.1. So what is the difference here with VS2015 and VS2017? Does VS2015 automatically include windows SDK header files but not in VS2017?

Related

How to use jsoncpp with Visual Studio 2022

I need my project to be able to use json format.
I was suggested this github : https://github.com/open-source-parsers/jsoncpp
I have been trying to integrate it to my project for multiple hours and still cant find the issue.
I still get these errors on my include :
#include <jsoncpp/json/json.h>
E1696 cannot open source file "jsoncpp/json/json.h"
C1083 Cannot open include file: 'jsoncpp/json/json.h'
I tried to go to C/C++ General->Additional Include Directories>
to add the "jsoncpp-master\include" directory
also tried "jsoncpp-master\include\json" directory
also tried to add the .h and .cpp found in the repository directly.
I have also tried a multitude of other things but I'm not sure it would be relevant to list them all here.
I was not able to find instructions to use it with Visual Studio 2022 on their github either.
Safest and most convenient way to use third party libraries is to use package manager like vcpkg
https://vcpkg.io/en/index.html
https://github.com/microsoft/vcpkg
Choose what build you want x86 or x64 and set default triplet in your environment variables
VCPKG_DEFAULT_TRIPLET
x64-windows - DLL Build 64-bit windows
x86-windows - DLL Build 32-bit windows
x64-windows-static - Static Build 64-bit windows
x86-windows-static - Static Build 32-bit windows
If you have added jsoncpp-master\include to C/C++ General->Additional Include Directories then you should use #include <json/json.h> instead of #include <jsoncpp/json/json.h>
Explanation : The compiler is looking inside the include directory. If you observer the file structure you can see json folder is located in the include directory and not jsoncpp.

CritSec.h not existent (Win 8.1)

I have this sample code I'm currently using to write a dll in c++.
In this file critsec.h is included.
However on my system (Windows 8.1 Pro 64bit) Visual Studio 2013 CE can't find the source file.
Am I missing some sort of SDK or something?
In the project file belonging you your example file, you see the following additional include directories (reformatted for better reading):
<AdditionalIncludeDirectories>
%(AdditionalIncludeDirectories);
$(MSBuildThisFileDirectory);
..\..\Common
</AdditionalIncludeDirectories>
And indeed, in ..\..\Common, you will find CritSec.h
How do you include this? There are two ways. If you you use #include "something.h" the file has to be at the same location where youre .cpp is. If you use #include than the header has to be at a directory in visaul studio.

Can I compile a Visual C++ project on Linux using xbuild?

I have an existing project that I compile on both Windows using Visual C++ 2008, and Debian Linux. This project uses a standard Visual C++ .vcproj file, and some .cpp and .h files. It does not rely on any Windows specific stuff. Just plain C++.
It compiles and run well on Linux, using a home made tool that reads the .vcproj file to generate a Makefile which is used with make to compile and link all files using g++.
The trouble is that with Visual C++ 2010 (and 2012), the format of the project files have changed. Even the name has been changed from .vcproj to .vcxproj. My home made tool cannot read this new project file to generate the Makefile.
Instead of upgrading the home made tool to support new project files, I was wondering if xbuild would be able to compile my Linux executable?
I tried first to compile my own (VC++2008) project, but xbuild complains that my project is a VS2003 project, which is not supported by xbuild. However when googling on this matter, I find that xbuild is supposed to support VS2005 project files. There are also some references to mdtool to support these old project files, but I seems to be integrated into xbuild now.
Furthermore, I tried to compile a Visual C++ 2010 example (HuoChess) got from the MSDN site. The result is
/Microsoft.Cpp.Default.props: Project file could not be imported, it was being
imported by [...] /HuoChessConsole/HuoChessConsole.vcxproj: Imported project:
"//Microsoft.Cpp.Default.props" does not exist.`
Now, this looks like the project file wants some Microsoft definitions of rules for the Cpp compiler. Should I fake these definitions to use gcc instead? How can I do this?
Is what I want to do ever possible with xbuild?
There is a project GCCBuild which you can use to build vcxproj projects in Linux. It simply uses same vcxproj but uses GCC to compile and build. There are multiple examples there too.
PS. I am the author of that project.

How to create empty Qt project in visual studio 2010

Using visual studio C++ 2010 Ult.
I have compiled and instaled Qt libraries and visual studio add-in is installed into VC++ so I'm basicaly able to build Qt applications using Qt templates ofered from VS add-in.
I'm also able to include Qt headers and all works just fine...
installation has been done using VSC++ command promt, full build using
configure and nmake then.
QTDIR and PATH are properly seted up.
Qt libs are installed into:
(QTDIR) C:\Users\Admin\Documents\Libraries\Qt
(PATH) C:\Users\Admin\Documents\Libraries\Qt\bin
BIG BUT:
when crating new empty(or other non Qt template) project I can't include any Qt header so my question is how to enable this.
I want to set this so I can in all my future projects simply write:
#include <Qapplication>
#include <Qlabel> //etc...
thanks alot.
Maybe you can use the user properties for that? Set up the include and library paths there, then you should have Qt available for all projects.
See here: http://blogs.msdn.com/b/vsproject/archive/2009/07/07/vc-directories.aspx
For some reason VS can't find Qt headers. I think the only possibility is that you have not specified Qt include paths in the project (not for VS, just for a project). VS add-in always specifies these paths according to the user settings. The basic ones are ($(QTDIR)\include), $(QTDIR)\include\QtCore and $(QTDIR)\include\QtGui. The last one is necessary only when creating non-console GUI applications.

Using Windows header files within Netbeans 6.8

I'm trying to make an windows application within Netbeans.
When using Visual studio it is no problem to use files like tchar.h
I have receaved a basic file structure containing those and I'm trying to get them to work on Netbeans IDE but it seems that Netbeans won't allow using files from Visual Studio.
I have tried to add the tchar.h file and all other file it required (including some C++ core files) and commenting the errors written in those care files:
#error ERROR: Use of C runtime library internal header file.
But netbenas can't find the tchar.h file while being in same folder...
If you're using gcc you might consider using the unix style wide characters instead of the microsoft specific version. Look at wchar.h
http://en.wikipedia.org/wiki/Wchar.h