Global include path on Windows on VS2013 - c++

I should add a global include path to my system (i.e. it's Google Test so I need to include "C:\gtest\include")
I appended it to the PATH environment variable and restarted VS2013. However, VS2013 still complains about the missing .h files.
What's wrong with this IDE?!?

First, you definitely don't want the PATH environment variable. You do want the INCLUDE environment variable.
Second, use a statement like SET INCLUDE=C:\gtest\include;%INCLUDE% to set it.
Third, that's only going to work in a command window that you're running command line builds in.
Fourth, so try setting it on your machine using This PC's properties "Advanced System Settings" Environment Variables dialog. Remember to restart your VS2013 after setting it so it picks up the new env vars.
Fifth, why not do a SET (with no arguments) after you've set your non-working INCLUDE variable and paste the result into your question so we can all see what your environment variables look like - then we might be able to help you better.
Sixth, it's going to end up being your misunderstanding of how things work. That's clear since you think the PATH env var has something to do with VC++ searching for include files. So why the gratuitous "What's wrong with this IDE?!?" slam? It's not winning you any friends.
Seventh, see the MSDN article Setting the Path and Environment Variables for Command-Line Builds for tips. It came right up when I googled for "visual studio include environment variable", and it has help for you.

Related

How to define custom build variables in Xcode

In Xcode 10, I'm creating a C++ project that uses the HEADER_SEARCH_PATH to define a list of header include paths. One of the paths contains an environment variable, e.g. ${CUSTOM_INCLUDE_ROOT}/boost_1_xx_0/include, where ${CUSTOM_INCLCUDE_ROOT} is supposedly an environment variable to be set on each dev's local environment to give a root include path - the reason is that this root dir is of user's own choice, so different users can decide on different root dir.
However, in Xcode 10 build settings, it doesn't seem that Xcode is automatically expanding ${CUSTOM_INCLUDE_ROOT} - causing the expanded header to look like: /boost_1_xx_0/include, and of course that causes compiler errors for #include <boost/something.hpp>
So, the question is: how does Xcode build settings reference environment variables, or is this possible at all?
Or a related question would be: if referencing environment variables in build settings is not possible, is it possible to define new custom variable such as ${CUSTOM_INCLUDE_ROOT} to be /home/username/globalInclude inside xcode?

Eclipse C++: fatal error: cheddar.h: no such file or directory

[RHEL v7.3, Eclipse Photon, C/C++ Project with Eclipse-generated Makefile]
Attempting to include a custom library named cheddar.h results in
Fatal Error: cheddar.h: no such file or directory
Research 1 and 2 suggests manually adding the include path by first alt-clicking the project in Project Explorer, and then manually adding the path :
Properties -> C/C++ General -> Paths and Symbols : Includes : Languages, GNU C++
No luck.
It works if I do things the old-fashioned way, and add the path to the makefile with a -I option, like so
-I/home/kmiklas/lib/
..but I feel like I'm working-around the issue, and I want this set up properly; the way it should be set up.
How do I correctly specify a custom include path in Eclipse? Tyvm :^)
What is wrong with CMake/Makefile?
I don’t know, but this just sounds like an XY problem. But what’s even more confusing is how you’re so reluctant to use a solution that you’ve already got (as in it’s bugging me).
Anyway
What may aid you in this is to ditch eclipse’s settings and just use the compiler’s. Eclipse uses (GCC/G++ (probably)). What you can do is set some environment variables DUN DUN DUHH!
These environment variables are aptly named: C_INCLUDE_PATH and CPLUS_INCLUDE_PATH. If, however, you want the same for both (you want to use it for both languages) you can just set CPATH.
You’re probably thinking: what else can I do with this marvel... and for that I direct you to the official GCC website.

assigning permanent custom paths to anaconda

This question has been asked, but oddly enough the answers are out of date or not sufficient.
I have installed anaconda, I have setup an environment running py2.7. I launch a win7 cmd prompt and type activate python27 (my custom python environment). I then import sys and then sys.path to see what my python paths are. They all point to variations of E:\Users\myname\Anaconda3\....
I want to add a custom path to this list so that it becomes permanent. Doing sys.path.append is not good enough as its not permanent. I have been reading that adding PYTHONPATH to the environment variables is not done any more, and that I should be adding my custom paths to the PATH system variables.
So could someone advise where and how I can assign my custom paths.
Okay thanks to my instructor I found this to work for me.
open a command prompt (just regular win cmd) and add a path like this where you see the J:\pythonTest you can add your own path this will put it into your path.
SETX PYTHONPATH "%PYTHONPATH%;J:\pythonTest"
One thing I noticed, because I had been trying all sort of ways to solve this problem, my user variables and system variables and a few duplicates of my custom path. I would advise removing them once you run the above command. I suggest removing them because I think I discovered some conflicts and my modules wouldn't run, removing the duplicates seemed to fix this conflict.

How to debug Visual Studio environment variable usage?

I am unable to change my PATH environment variable from Microsoft Visual C++ 2010 Express using a project relative path.
Relevant paths:
Solution path: D:\School\dva303\project\Woods\
Project path: D:\School\dva303\project\Woods\Woods\
Absolute path to needed DLL directory: D:\School\dva303\project\Woods\Woods\allegro-5.0.10-msvc-11.0\bin
When I use the absolute path:
Project Properties / Debugging / Environment: PATH=D:\School\dva303\project\Woods\Woods\allegro-5.0.10-msvc-11.0\bin
It works! But if I change it to a project relative one using $(ProjectDir):
Project Properties / Debugging / Environment: PATH=$(ProjectDir)\allegro-5.0.10-msvc-11.0\bin
It fails and I get a message that the DLL can not be found on my computer. It does not matter if I use a \ after $(ProjectDir) or not.
Questions:
How do I get it to work?
How do you debug situations like this one when a Visual Studio environment variable is not behaving as you expect it to? Is there a way to print it out or by some other method see what it will be evaluated to?
You can simply add a post build task to echo out $(var), and you'll see it in the output window.
I think your actual problem is that your environment variables don't propagate to the application you run/debug. You can use SysInternals' Process Explorer to check this. If so, just add another post build task to copy the required DLL files to the same directory as your output.
If you just want to see the values of $(ProjectDir) then if you go in to your vcxproj properties, then anything then lets you get to the "macros" view. Such as adding a new include path will list these out and their values. But you'll still need the echo trick for anything "dynamic" or to check nothing is overriding it.

Environment variables in Visual Studio 2013

I'm trying to set my project include to the path %OPENCV_246%\..\..\include
This resolves to the path F:\dev\opencv_246\build\include
However, when setting the project includes, that path will not resolve and as a result the included headers break.
I've tried both %OPENCV_246%\..\..\include and $(OPENCV_246)\..\..\include with no luck.
Using the path directly fixes my includes, but I'd like to have a better way of managing the path through environment variables.
In the screenshot I've added both for clarity, If anyone could point out the step I'm missing here I'd appreciate it.
EDIT: Variable OPENCV_246 contains value F:\dev\opencv_246\build\x86\vc11
Dev studio won't recognize any environment variables that have been changed since it was started, so if you change one, a restart is required (of Dev studio, not the computer).
https://superuser.com/questions/107521/why-are-changes-to-my-path-not-being-recognised
This sounded similar to my problem, which was getting VS2013 to acknowledge a change I made to my environment variable (in my case QTDIR). Even after a restart and a shutdown, it obstinately hung on to the old value !! (you can see the value if you go to edit a project setting, hit the "Macros" button, and scroll down the list to find e.g. "$(QTDIR)" )
Here it suggest VS2010 cahed values heavily, but 2013 seems even more keen !
After some FindInFiles for the old path, it seems that VS2013 caches environment variables in your .vcxproj.user file. I have no idea how it got in there in the first place.
So I deleted the entry, closed the solution, checked the file again in WordPad to make sure the entry hadn't been put back in. Then I re-opened the solution, but the old value was still there in the Macros list !
Closing VS seems to have done the trick. Now it seems to have the right path - although I'm sure I checked after I first opened the solution and QTDIR wasn't in the Macros list at all - maybe I'm confused...
Well, it all seems to be working now, and my project builds and links to my Qt libs without complaints :-)
And, the entry in the vcxproj.user file hasn't come back. So I still don't know how it got in there. Maybe I did something to cause it a while back in a previous version of VS...