简体   繁体   中英

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 eg "$(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...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM