What should I install to use namespace Windows::Devices in c++? - c++

Now I am going to connect to device using bluetooth, so I have got some source code.
It uses namespace Windows::Devices, but my visual studio gives me compile error.
using namespace Windows::Devices;
I guess I have to install some packages additionally, but I am not sure what I have to install.
If anyone knows, please help me.

Since the question is tagged c++ I'm going to assume that that's the programming language you are using. The most convenient way to consume Windows Runtime types from C++ is through C++/WinRT. It consists of both a base library as well as a code generator. The code generator is responsible for providing the "projected types" (see Consume APIs with C++/WinRT), generated into namespaces such as Windows::Devices.
It's common for a project to generate the headers containing the projected types on the fly, that can then be included like any other header. A project created using the C++/WinRT VSIX extension does that. Those projects have a reference to the Microsoft.Windows.CppWinRT NuGet package that contains the code generator, as well as project properties to drive it during a build.
Previously, the header files containing the projected C++/WinRT types had been delivered through the Windows SDK. They are still part of the SDK, and can be used by client code, even though it's preferable to use the NuGet package instead. You'll find the Windows.Devices.h header file under %WindowsSdkDir%Include<WindowsTargetPlatformVersion>\cppwinrt\winrt, so to use this namespace, that's the file you'll need to include.

Related

Embarcadero windows libraries and packages

This is my first time with Embarcadero RAD Studio (C++, not Delphi) and, despite of many searches on its site and the rest of Internet, I'm still confused with some concepts.
My goal, by now, is to set a OpenGL Core Profile and go on with OGL stuff (which I'm acquainted with). With other IDE/Compiler I'd add the opengl32 library, use wglCreateContextAttribsARB and glew.
Digging into Embarcadero files I find C:\Program Files (x86)\Embarcadero\Studio\20.0\lib\win32\release\psdk\opengl32.lib, C:\Program Files (x86)\Embarcadero\Studio\20.0\lib\win32c\release\psdk\opengl32.lib (note the 'c' after win32, what's that?) and C:\Program Files (x86)\Embarcadero\Studio\20.0\lib\win64\release\psdk\opengl32.a
So I suppose I could just "Project->Add to Project..." the library, instead of "import" from Windows system as it seems was needed many years ago. But I'm confused because RAD may add the required libs on its own, at least for controls, right?
But I've meet with ".pas" files, which seems to load anything needed. Actually, the C:\Program Files (x86)\Embarcadero\Studio\20.0\source\rtl\win\Winapi.OpenGLext.pas seems enough, so I could avoid glew. My confusion is that I don't know if a ".pas" file can be used (and how) for VCL C++, not Firemonkey, not Delphi.
I have not be able to find wglCreateContextAttribsARB, nor a replacement for setting a Core Profile context.
Summarizing:
Do I need to add system libs? How?
How to use ".pas" files?
Which is the difference between win32 and win32c dirs?
How to set a OGL Core Profile context? I mean, should I go with the route of retrieving a function pointer to
wglCreateContextAttribsARB or RAD provides another way?
Does RAD provide for C++ a replacement of glew?
1.Do I need to add system libs? How?
Normally yes. unless you are using a component that has taken care of adding the library. In Win32 you have to use #pragma link "opengl32.lib" and in win64 you have to add #pragma link "opengl32.a" to your cpp code.
2.How to use ".pas" files?
You do not need to add the files in the source directory to your project. Embarcadero is nice enough to include the source code for most of its components with the product. This is so you could understand how it works and if you need to change some behavior you can create a new class derived from the class that you want and override the function in question. In general C++ builder allows adding Pascal units to C++ project and it will take care of creating the header file automatically. But in your case it is not necessary.
3.Which is the difference between win32 and win32c dirs?
C++ builder comes with 2 32 bit compilers for Windows. One is clang based and supports C++14 and the libraries that have been compiled with it are in win32 directory. The other one is the classic compiler and the libraries that have been compiled with it are in win32c directory. Unless you have checked the "Use Classic Compiler" in project settings, you don't have to worry about it.
4.How to set a OGL Core Profile context? I mean, should I go with the route of retrieving a function pointer to wglCreateContextAttribsARB
or RAD provides another way?
I'm not aware of any components that RAD studio may provide. You should search https://torry.net/ or http://www.delphipages.com/ or many more places that exists out there for a component that helps you whith what you need.
5.Does RAD provide for C++ a replacement of glew?
What is "glew"?

How to make Visual Studio 2017 C++ project more portable between computers?

I am developing a project on C++ which relies on many of third-party libraries (*.lib files and *.h files). I store these libraries in a folder which is not dependant to project, like C:/thirdpartylib. Relative paths is not an option, since it becomes way too long. I have defined connections to libraries in linker setting and in general C++ settings.
But when I pass the project to supervisor he has to reset all paths to libraries to match his environment. We use git, and the project file is being tracked. He stores thirdparty libraries in another way than me.
Is there any way to make a project more portable? Maybe it is possible to store paths in some sort of config files?
As #gaurav says, the way to deal with this in Visual Studio is with property sheets. It's unfortunate that this term is used for two different things in VS, but I guess they just ran out of names (spoiler alert).
These are very powerful, once you learn how they work, and they're just what you need here because they let you define macros, and these macros can in turn be used in the rest of your project to refer to the (volatile) location of your various libraries. This is a trick that everyone who uses VS should know, but it seems that a lot of people don't.
I don't think it's worth me trying to walk you through the mechanics of setting one up here because Microsoft already document it in the Visual Studio help file. Suffice to say, you do it in the Property Manager, that should help you track down the relevant information.
There is also an excellent blog post here which I recommend you read before you do anything else:
http://www.dorodnic.com/blog/2014/03/20/visual-studio-macros/
It's also on Wayback Machine here:
https://web.archive.org/web/20171203113027/http://www.dorodnic.com/blog/2014/03/20/visual-studio-macros/
OK, so now we know how to define a macro, what can we do with it?
Well, that's actually the easy part. If we have a macro called, say, FOO, then wherever we want to expand that macro in some project setting or other we can just use $(FOO). There's also a bunch of macros built into the IDE as listed here:
https://msdn.microsoft.com/en-us/library/c02as0cs.aspx
So, you, I imagine, will want to define macros for the include and lib directories for each of your external libraries and you can then use these to replace the hard-coded paths you are currently using in your project.
And that, I reckon, should sort you out, because the definitions of the macros themselves are stored in a separate file, external to your project file, and different users / build machines can use different files. IIRC, these have extension .props.
Also, you can define a macro in terms of another macro or macros, and that makes the job easier still.
So, who still thinks that Microsoft don't know how to create a build system? Visual Studio is a fantastic piece of software once you get used to it, there's just a bit of a learning curve.
The way to go for large project is to use a package manager. There are some good options out there. Perhaps in windows and visual studio you can use vcpkg or NuGet unmanaged.
If you cannot use a package manager for some reason, the next thing to do is to commit all the dependencies to the GIT repo. If you only target windows platforms like windows 8 or 10 and want to support only VS2017 then committing the compiled dependencies is not a problem. The downside is that the repo will become huge.
For a tiny school project the latter option is viable.

MS Studio 2012 - How to make it behave more like Netbeans/Java?

I started yesterday on learning C++ with Microsoft Visual Studio 2012. I have a background of 1-2 years with Netbeans and Java, and I use the code completion features a lot.
So I got a few questions here for MS Studio 2012:
In Netbeans you can alt+I to fix imports, what is Studio counterpart?
In Netbeans/Java if you type File file = new File(); and then press alt+I, it will automatically add import java.io.File;
I am really stunned by the following thing though in MS Studio 2012, which I would like to solve:
In the first "Hello World!"-tutorial I have to write to the console using cout << "Hello World!", so I typed that... But it did not give me any option to automatically do using namespace std; and/or #include <iostream>.
Is there a way to make whole MS Studio 2012 behave as closely as possibly to what I have been used in Netbeans/Java?
First of all, C++ is not Java, and #includes are not imports. The IDE can not know in which headers the classes and functions you want to use are declared/defined. To do that, it would have to parse any header inside the include path. And since per sé any file can be used as a header, i.e. can be included, it would have to (try to) parse any file in the whole include path.
Again, C++ is not Java, so compared to Java C++ has some strengths and weaknesses. One of the latter is the need to manage your includes manually.
Update: As has been noted by Martin Ba, there are tools that can give you assistance on a set of classes, e.g. classes from common libraries like the standard library and the classes defined inside your VS project, but those are third party tools and have to rely on manually managed databases that would need to be extended in order for the feature to work properly in the presence of other libraries.
tl;dr you can't get the automatic import for everything in C++
The refactoring support of VS cannot do this.
However, there is 3rd party Software - Visual Assist X - that has the ability to try to include the right header file for a certain symbol. See: Auto Using and Add Include Directives
The problem for your context would be that it is commercial software that you also can only use with a pay-for non-express version of VS.

Referencing an unmanaged C++ project within another unmanaged C++ project in Visual Studio 2008

I am working on a neural network project that requires me to work with C++. I am working with the Flood Neural Network library. I am trying to use a neural network library in an unmanaged C++ project that I am developing. My goal is to create an instance of a class object within the Flood library from within another project.
There is plenty of documentation online regarding how to reference an unmanaged C++ project from within a C# project, but there is not enough information on how to reference one C++ project within another. Similar to how I would do it in C#, I added the Flood project as a reference in my other project, but I have tried all sorts of techniques to work with the object. I have attempted to use the #include directive to reference the header file, but that gives me errors stating that I need to implement the methods declared in the header file.
How to add a reference in unmanaged C++ and work with the class objects?
Yes. You need to do two things:
#include the respective header files, as you did
Add a reference (Visual C++ supports two types, "dependencies" which are outdated and should not be used anymore, and "references" which are the correct ones). Use them to reference the other project, which must be a part of your solution. Meaning, in this case you must be able to COMPILE the other project.
Alternatively, if you do not have the source code, or you do not wish to compile the 3rd-party code for any other reason, you may also reference a compiled binary. The best way to do it is pragma comment lib. If this is what you need, please comment and I will edit my response.
Looking at the provided vcproj file, the flood distribution is really weird, and builds an exe file.
As such, the supported way to use Flood in your own project is not via two projects (being your application and a "libflood" project) - But simply to add all the flood cpp files to your own project and build that.

Are there Windows API binaries for Subversion or do I have to build SVN to call the API from Windows C++?

I want to call a Subversion API from a Visual Studio 2003 C++ project.
I know there are threads here, here, here, and here that tell how to get started with C#.NET on Windows (the consensus seems to be SharpSvn, which I've used easily and successfully on another project) but that's not what I want.
I've read the chapter on using APIs in the red-bean book which says:
Subversion is primarily a set of C libraries, with header (.h) files that live in the subversion/include directory of the source tree. These headers are copied into your system locations (e.g., /usr/local/include) when you build and install Subversion itself from source. These headers represent the entirety of the functions and types meant to be accessible by users of the Subversion libraries.
I'd like to use CollabNet Subversion but there doesn't seem to be API binary downloads, and I'd just as soon not build the whole thing if I can avoid it.
Considering another approach, I found RapidSVN's C++ API, but it doesn't appear to offer Windows API binaries either and seems to require building SVN (which I would be willing to do as a last choice if RapidSVN's API is higher-level than the stock SVN offering.)
Does calling the API from C++ in Windows have to be this much more work compared to using SharpSvn under .NET, or is there something I haven't found that would help me achieve my goal?
You need the dev (e.g. svn-win32-1.6.16_dev.zip) package from here. Probably download also the binaries (e.g. svn-win32-1.6.16.zip) of the tools (DLLs are there).