Missing guiddef.h in project - c++

I am new to Visual C++.
I am trying to use library A that in turn uses another library B. When I try to include the header of A, I get an "Error C2061: syntax error : identifier 'GUID'". This error is triggered in a header in library B. When I examine the line that throws the error, the issue is that the header in library B is using a definition found in Guiddef.h, which is a microsoft header.
The problem is that I can't seem to be able to add this header or to create a project that adds it.
I am using Visual Studio 2010 Premium.
Any ideas of what I am doing wrong?

Don't know what you mean by add it to a project or create one that adds it ,but when guiddef.h is on your system and your directories (in common properties) to your MSVC environment are correctly setup ,you just have to add #include <guiddef.h> before the including of lib-headerfiles to your cpp or h files and everything will (should) be fine.

guiddef.h is part of the Windows SDK. If you have VS 2010 Express the SDK is not included, you'll need to download it separately.
If you're using a VS SKU that's 'above' Express, the SDK should already be installed (I'm not sure if you can deselect it or not when in stalling). By default it'll go into:
C:\Program Files\Microsoft SDKs\Windows\v7.0A\
The "Visual Studio Command Prompt" shortcuts that VS installs should set the INCLUDE environment variable appropriately. And a default C++ project should also have the include path setup appropriately, but it can be changed in the project's "VC++ Directories" property (you should check that). If you have a per-project setting here that is wrong, change it there.
However, if your 'IDE-wide' VC++ Directories properties that are inherited by every (or at least most) C++ projects is messed up, follow the instructions on this blog article to fix the global VC++ Directories settings in VS 2010:
http://blogs.msdn.com/b/vsproject/archive/2009/07/07/vc-directories.aspx
Specifically:
If you open up the Property Manager view to see the property sheets associated with your project, you’ll see that one of the property sheets is named Microsoft.Cpp.Win32.User. This property sheet is actually stored in LocalAppData, just as VCComponents.dat file was, in the directory %LocalAppData%\Microsoft\VisualStudio\10.0. Using the property editor on the property sheet (just right-click on this property sheet node and select Properties...), you can see that you are able to make edits directly to this file. Since all projects, by default, import this property sheet, you are effectively editing the VC++ directories in the same way you were able to do before.

It's possible (though not necessarily true) that you need to include a library as a linker dependency. I'm assuming here that you're already using #include (and have the correct case, with a lowercase 'g')
My suggestion:
Open up the project that has the
header included
open the 'project' menu, and select
'properties'
Under 'configuration properties'
select 'linker'
under 'linker' select 'input'
take a peek at the 'additional
dependencies' field (right at the
top on the right hand side). You
may see some libraries listed there.
Make a note of any libraries
included as dependencies, and repeat
these steps in your 'broken'
project. Add the appropriate libraries to the 'broken' project, if needeed.
You probably don't need the same dependencies in both projects, but if you do need to link a library in the borked project, you should be able to narrow down which one it is you need and include it in the dependency list.
Hope that helps, or at least doesn't steer you too far off course!
edit:
Actually, for some of the headers in the windows API, you might not be able to include them 'alone' (I'm not sure if guiddef.h is one of them), but they should be included as a sub-header of windows.h.

Related

How do you seamlessly integrate a third party library into Visual Studio 2017?

I want to take libFoobar/lib and libFoobar/include and tell VS2017 to make compiling and linking with them work by default for all projects.
In earlier versions there was a global setting for compiler directories but I believe they deprecated that and made it completely project level.
You can manually add a third party library to a project by configuring its project settings
Under C/C++ / additional include directories and linker / input / additional dependencies.
I don't want to have to store or memorize the names and locations of all of the .lib files or /include directories that I might need and manually re-enter them every time I start a new project or have to recreate an existing project.
There may be a way to create and maintain a project template which would be a solution.
You can add .libs to the project from the source code via #pragma comment(lib, "libFoobar.lib"). The most convenient overall method that I've got so far is to add /libFoobar/lib to the PATH variable, add the libs via #pragma to each header file, and manually add the /include directory to each project. But that's a hack.
I did try to use "INCLUDE" and "LIBPATH" environment variables but they did not exist and adding them did nothing:
https://learn.microsoft.com/en-us/cpp/build/reference/cl-environment-variables?view=vs-2019
They might be valid on 2019 only.
Yes, project templates are a thing, and should accomplish this.
Here's some documentation I found by Googling "VS project templates":
How to: Create project templates
Instead of making project templates you can modify the default project property sheets.
Go to View->Other window->Property manager then open one of the nodes for the machine type you are working with (debug and release builds share the actual property sheet file). Right click on Microsoft.Cpp..user and select Properties, you can then make changes just like any other property sheet and the settings will be picked up by projects generated using the default wizards.
This is the replacement system for the mentioned prior global setting.

Any way to include a batch of Library and Directory paths to "Include Additional Directories" Visual C++

Currently, when working on a new solution in Microsoft Visual Studio 2017 (C++), my team has to include a bunch of libraries and directories individually. Which is tedious and prone to mistakes. Is there anyway to be able to include one path(Environment Variable) in "Additional Include Directories" that contains all the paths to the "Includes" we need without individually including each and every path or any other solution? Right now, when we create a new solution we have to repeatedly add every solution individually.
Go to view->Other windows->Property manager and then open one of the project nodes and then one node for each of the platforms of interest (that is Debug|Win32, Debug|X64), and right click on the Microsoft.Cpp..User node and select properties.
Now, you can edit this property page just like a project properties but the settings will be applied to all projects (even already created projects).

visual studio not seeing my include files

This may be a very simple question but I haven't been able to figure it out so any help is appreciated.
I have a header that is located in a general folder because I want to use it in several projects for example:
C:\user\geninclude\program\header.h
I created a new empty project with a very simple main, in the main I put
#include <program/header.h>
I then went to the project properties and in VC++ in include directories added C:\user\geninclude\
but when I tried to build the program the program tells me it cannot find header.h because is not in the current directory or in the build system path.
I also tried in the project properties in C/C++ general Additional Include Directories adding C:\user\geninclude\ but still the same error.
I know is something simple I am missing, but I don't know what, I am very new to this just learning.
For reference I am using Visual Studio 2013.
Thank you in advance for your help.
UPDATE: Thank you all for your kind responses, I have tried everything you have told me (check release vs debug in both instances, change / for \ and <> for "", and double checking the header and still the system does not see it. It really is very weird. I'll keep trying...
Please check if your file is really an header file otherwise it won't appear on include.
What you can also do (as a workaround if you need that method fast) is to put your header file (or folder with header files) on the visual studio "include" folder. The path should look like this "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include"
PS: You should also check the properties configuration when you're adding the path to VC++ include directories. You could be adding the path to debug configuration and trying to run it in release mode.
You do indeed want
Project Properties -> Configuration Properties -> C/C++ -> Additional Include Directories
(or something close to that; I'm using VS 2008). Make sure the configuration you're editing in the top left (debug/release) matches the configuration you're building with (typically visible up top in the main window). So it sounds like you may have done it correctly; I'd double-check for the file's existence in that location. You could also try program\header.h instead of program/header.h. If none of those work, try adding C:\user\geninclude\program to the include directories (no \ at the end) and change it to #include "header.h". If that doesn't work either, you've almost surely got the header file in the wrong spot.
Another thing that can cause include files not being picked up is a difference between the platform set in your c++ project's Property Pages and your "Active Solution Platform" in configuration manager. Can just check if one is set to x64 and the other x86
check if you have specified the path correctly. for example I had written cpp instead of c++ and therefore suffered a lot and wasted like an hour searching here and there.
For Visual Studio 2019 users:
Project(P) > yours_project_name properties(P) > Platform Toolset Visual Studio 2019(V###)
Reasoning: You might download the project from Online and they used other version of Visual Studio as Platform.
Project(P) > yours_project_name properties(P) > Windows SDK Version ##.#(latest installed version).
Reasoning: You might download the project from Online and they used version SDK 8.0 while you have SDK 10.0
ntucvhw

Visual Studio Cannot open include file; No such file or directory

Linking files is going to be the death of me.
So, I have had this problem many times before in both Visual Studio for C++ and Eclipse for Java. Right now I'm having problems in visual studio while trying to setup a project so I can start messing around with the Kinect SDK. The first thing I did was to include the NuiApi.h
#include <NuiApi.h>
I made sure to go into the VC++ directories and add the correct include directories $(KINECTSDK10_DIR)\inc and $(KINECTSDK10_DIR)\lib\x86 for the library directories. I also went to the Linker and added the Kinect10.lib in the additional dependencies in the Input section.
I still had the problem even after including these directories into the project. So I did some exploring and went to C/C++->General and added the include directories in the "Additional Include Directories" portion again just to see if that would fix it... that did nothing.
So I went back to the linker and added the library directories under General in Additional Library Directories to see if that would do anything and it still has not.
I'm at a complete loss right now and am so confused as to why these files aren't being included correctly! I swear this happens every time I try to work with a new API and I have to fiddle with it until it starts working for some reason. Am I doing something wrong? Am I missing something stupid? Does anyone have any ideas?
The difference between quoted and the angle-bracket form is explained here for visual studio. In principle, the quoted form is used for project specific includes, whereas the angle form is used for system libraries. In your case, the angle-bracket seems to be the right form.
What you have to do is to add the include to the C++ directories :
Right click on project -> Properties
VC++ directories
You should keep in mind that this setting is configuration-dependent, i.e. you have to do it for debug mode, but you'll have to repeat it for release mode.
Finally, you should make sure that the environment variable KINECTSDK10_DIR points to the right location (Windows+X -> System -> Advanced system parameters -> Environment variables). Attention: if you edit these parameters, you'll have to restart visual studio so that the new environment is taken into account.

Visual Studio: C++ Project Include Paths sharing over Repository

I was wondering how should I add my library include paths and linker paths in Visual Studio so that when I add my project to a repository, another developer checking out my project would not need to go through all the include paths and change them for his own machine. So, I am kind of looking at something like ${MY_THIRD_PARTY_LIB_INCLUDE_PATH}\tbb\include and ${MY_THIRD_PARTY_LIB_LINKER_PATH}\tbb\lib\ia32\vc11 so that someone accessing the project can just change MY_THIRD_PARTY_LIB_INCLUDE_PATH and MY_THIRD_PARTY_LIB_LINKER_PATH and everything works as intended. Can somebody suggest a best practice around this or may be how to accomplish what I just described?
In VisualStudio 2012 I use Project Properties
So if you go to the Propery Manager you Add a new Project Property Sheet to you project. From there, a couple of things can be set
User Macros - We create a macro here and put in a path for our environment. We crate a Macro called CUSTOM_DEBUG_PATHS, and then in the project we set the Debugging->Environment to path=$(PLA_DEBUG_PATHS);$(PATH)
The other thing that we do in the Project Property Sheet is change our Include and Library directories. We have everyone use relative paths, but you could put in an environment variable or something in here so that everyone could use the same file.