Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

screenshot

like image 522
LCartwright Avatar asked Dec 08 '13 15:12

LCartwright


People also ask

How do I set environment variables in Visual Studio?

To access this page, select a project node in Solution Explorer, select Project > Properties from the Visual Studio menu, and then select the Environment Variables tab. Specifies the name of an environment variable that will be used when the project is built or when the project is run from Visual Studio.

How do I see my environment variables?

On the Windows taskbar, right-click the Windows icon and select System. In the Settings window, under Related Settings, click Advanced system settings. On the Advanced tab, click Environment Variables.

How do I create an env code in Visual Studio?

Once you have opened the folder, click on the Explorer icon on the top left corner of the VSCode (or press Ctrl+Shift+E) to open the explorer panel. In the explorer panel, click on the New File button as shown in the following screenshot: Then simply type in the new file name . env ...

What are environment variables in C#?

We as developers might like to control the behavior of an application based on the phases the application is in. Environment variable indicates the runtime environment in which an application is currently running.


1 Answers

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...

like image 166
Timothy Pitt Avatar answered Sep 22 '22 02:09

Timothy Pitt