Getting "Cannot open include file: 'atlbase.h': No such file or directory" error
Asked Answered
B

5

23

I am swapping machines (between two Windows 8.1 laptops) and have just loaded the project I'm working on from TFS. On one machine it compiles, on the other it does not and gives the first error

error C1083: Cannot open include file: 'atlbase.h': No such file or directory

On both laptops I am running Visual Studio Ultimate 2013. On the first laptop I've checked to see where it is picking up atlbase.h and it is from C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\atlmfc\include i.e. from the Visual Studio 2012 installation directory. On the new machine I do not have Visual Studio 2012 installed so the directory C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\atlmfc\include does not exist.

Other people have similar problems (e.g. Ramilol's question) because they are using Visual Studio Express. I am using Ultimate.

It could be an environment variables problem (as suggested by raj raj) but my include directory paths under VC++ Directories are $(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSDK_IncludePath) as required.

My general question is "how do I fix this?" but I'd also be interested to know how I check and set the value of $(VCInstallDir) since C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include does have atlbase.h in (so I am flummoxed as to why it is not picked up).

========== EDIT 1: Rewording ==========

Let me have another go at wording this question.

I have loaded a Visual Studio 2013 project onto a new build laptop from TFS. It will not build and gives errors like error C1083: Cannot open include file: 'atlbase.h': No such file or directory. The file atlbase.h is present on the new machine, in the directory C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include.

In my project's properties my include directory paths under VC++ Directories are $(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSDK_IncludePath)

How do I check what those macros are set to, and if they are not where atlbase.h is (i.e. C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include) how do I fix that?

========== EDIT 2: Microsoft Visual C++ Redistributables installed ==========

Responding to jp2code's answer the machine that works and the one that does not have a similar array of Microsoft Visual C++ Redistributables installed as the following screenshot shows (the working machine's on the left):

MSVC++RedistScreenshot

========== EDIT 3: Environment variables ==========

In his answer, pje explains how to look up the environment variables. %VCInstallDir% is correctly set to C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\ But if I right click on the line #include <atlbase.h> I get this error which suggests that despite %VCInstallDir% being correct, that is not where VS is looking:

open file error screenshot

========== EDIT 4: Platform toolkit setting ==========

Another possibility is the Configuration Properties | General | Platform Toolset project setting, suggested by manuell in the comments and Michael Burr in his answer. For the project it is set to set to Visual Studio 2012 (v110) but the only other option listed in the drop-down is v110_wp80, which, when selected, becomes Windows Phone 8.0 (v110). If I hand edit the .vcxproj file in notepad and reopening the project in Visual Studio Ultimate 2013 the property page now lists the Platform Toolset as Visual Studio 2013 (v120) (not installed).

If I start a new C++ Windows Store project I can set Platform Toolset to Visual Studio 2013 (v120) without issue, in fact it is the only option listed in the drop-down. (N.B. The new project has Target Platform Version set to 'Windows 8.1', and it is greyed out, so I cannot change it, while the failing project has it set to Windows 8.)

========== EDIT 5: Entire project settings file ==========

In the comments Michael suggests that "maybe posting the .vcxproj somewhere (like as a gist on github) might be helpful". I have posted it here.

========== EDIT 6: Uninstalling and reinstalling Visual Studio 2013 Ultimate ==========

Has no effect, the same error recurs.

Bookstand answered 11/12, 2013 at 17:35 Comment(17)
The VS2013 install on these machines is a Big Mess. Usually caused by having an earlier version on them, like Preview or Trial, and not properly uninstalling them. So the installer randomly skips steps because the registry has a memory of sub-packages already being present. Very hard to fix.Abbacy
It's a fresh build - no old versionsBookstand
ATL is installed with Visual Studio. If you don't have ATL files in the dfirectory you are looking them for at, then perhaps you unchecked respective box when you were installed VS... I suppose you need to go there and fix in through installer, because there is no other way to obtain ATL from, other than with [a more] complete VS install.Downtime
As I say in the question I do have ATL files in C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include, exactly where one might expect them. But that's not where Visual Studio is looking for them. I suspect it is looking for C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\atlmfc\include which does not exist on the second machine because I only have Visual Studio 2013 installed on that machine.Bookstand
What is the value for "Platform toolset" in General properties?Suction
Very interesting @manuell, it is set to "Visual Studio 2012 (v110)". The drop down only contains two options though, "Visual Studio 2012 (v110)" and "v110_wp80" which becomes "Windows Phone 8.0 (v110)" when first selectedBookstand
You should try to create a new solution and see is those weird options are here, too.Suction
I don't understand. Your project clearly WANTS VS2012, and build correctly when VS2012 is here, and fails to build when VS2012 is not here. The solution: edit your solution/project files with notepad and clean-up all references to VS2012.Suction
manuell, Michael made a similar suggestion. After editing the .vcxproj file in notepad and reopening the project in Visual Studio Ultimate 2013 the property page now lists the Platform Toolset as "Visual Studio 2013 (v120) (not installed)"!Bookstand
Uninstall VS2013 and install it again. Do not try anything with your legacy project, start VS and try to create a new project. If you can't (with the weird "not installed"), then your are in trouble. See first comment from Hans. If it works, load your updated project (the one you cleaned of any vs2012 refs)Suction
But Manuell, even without uninstalling and reinstalling a new project works OK, I can (only) target 2013.Bookstand
@dumbledad: maybe posting the .vcxproj somewhere (like as a gist on github) might be helpful.Terisateriyaki
I have posted it hereBookstand
A new project works OK but you have not cleaned-up your vcxproj. It still contains some <PlatformToolset>v110</PlatformToolset>Suction
I did, but I swapped it back when it rendered as Visual Studio 2013 (v120) (not installed) and gave a compiler error (though it is a different error: "error X5608: Compiled shader code uses too many arithmetic instruction slots (122)").Bookstand
I strongly resist to post an answer saying "make the project from scratch, adding source file one by one" :-(Suction
It may come to that manuellBookstand
A
11

On the new machine I do not have Visual Studio 2012 installed

Well, look no further, that's your problem. Your project targets the VS2012 toolset to build a Store project that runs on Windows 8.0. You can still open it in VS2013 but it can only be built if you have VS2012 installed as well. In other words, you must have the v110 toolset available on the machine. You don't.

Short from installing VS2012, you will have to re-target to 8.1 to get it to build with the VS2013 toolset (v120). Right-click the Solution node in the Solution Explorer window and select "Retarget Windows Store projects to Windows 8.1".

Do fret a bit about that laptop, it remembers too much about VS2012. Sounds like it had it once installed but it wasn't uninstalled properly.

Abbacy answered 27/12, 2013 at 18:2 Comment(4)
Wouldn't one expect an upgrade feature from 2012 to 2013 then?Joni
Yes, I described it. "Retarget Windows Store" menu item. They made remarkably little effort to support targeting 8.0 in VS2013, understandably when the upgrade to 8.1 is free.Abbacy
Owh I see. I was used to a full wizard kicking off fixing my projects and generating reports when I open them in new vs version. (On the other hand, am also used to re re recreating vs projects to get them right)Joni
Hans - that's interesting. Unfortunately retargeting to 8.1 reveals (or causes) other problems that prevent the project building: error X5608: Compiled shader code uses too many arithmetic instruction slots (122) but I can set to work on thatBookstand
E
6

If you want to see the value of $(VCInstallDir) or any other Visual Studio macro, then open the Developer Command Prompt for VS2013 (this should have installed with your VS 2013 install). In the prompt type: echo %VCInstallDir%. This will print the current value of the $(VCInstallDir) macro. If you want to change this to a different directory, then type set VCInstallDir=<directory path>, where <directory path> is the path to your desired directory (presumably C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include in your case).

Hope this helps, cheers!

------edit-------
As a side note, it is possible that these macros were imported with the 2012 project that you were trying to load and compile with 2013. If it turns out that it was your $(VCInstallDir) macro that was wrong, then that would explain why.

Elviraelvis answered 19/12, 2013 at 7:6 Comment(2)
I've checked %VCInstallDir% (thanks for explaining how to do that) and on both machines it is C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC which leaves me doubly puzzled as to why it is not seeing file :-(Bookstand
Hang on, they are different. The failing machine is missing the trailing `` let me see if that helps ... noBookstand
T
6

Check that the "Configuration Properties | General | Platform Toolset" project setting is:

Visual Studio 2013 (v12)

and not something like "Visual Studio 2012 (v110)

Terisateriyaki answered 20/12, 2013 at 21:48 Comment(6)
It isn't, it is set to Visual Studio 2012 (v110) but the only other option listed in the drop-down is v110_wp80, which, when selected, becomes Windows Phone 8.0 (v110). Given that Visual Studio 2013 is the only version of Visual Studio installed on the machine what do I need to do to get the Visual Studio 2013 (v12) platform toolset setting you mention? It's also odd that the VS2013 page for this property only mentions Visual Studio 2012 as an option: msdn.microsoft.com/en-us/library/8x480de8.aspxBookstand
Is the project a 32-bit project or a 64-bit project? Were 64-bit tools installed in this VS2013 installation? Does a newly created C++ project offer the VS213 (v120) Platform Toolset?Terisateriyaki
Also, it might be worth trying: close VS, backup then open the .vcxproj file in notepad, and change all instances of <PlatformToolset>v110</PlatformToolset> to <PlatformToolset>v120</PlatformToolset> then see what VS2013 does.Terisateriyaki
If this wasn't so frustrating it would be funny. After editing the .vcxproj file in notepad and reopening the project in Visual Studio Ultimate 2013 the property page now lists the Platform Toolset as "Visual Studio 2013 (v120) (not installed)". Any idea why VS2013 thinks that VS2013 isn't installed?Bookstand
@dumbledad: Don't know. I think a reinstall is in order (maybe after an uninstall).Terisateriyaki
I uninstalled and then reinstalled Visual Studio Ultimate 2013. The same error and symptoms recur.Bookstand
S
5

Possible solution

  1. Get Process Monitor
  2. Filter for atlbase.h

this way you will know exactly where Visual Studio is looking for atlbase.h. Process monitor will show you the failed file-open attempts.

At this point you will be able to solve the problem by

  1. make symbolic links (messy)
  2. fix the include directory paths (better)

Update Here is how you filter for file operations:

filter settings

Don't forget to click Add after setting the filter parameters.

Susurrate answered 14/12, 2013 at 12:9 Comment(1)
That sounds a useful tool George. How do you filter by filename? The list of filter possibilities I get are Architecture, Authentication ID, Category, ... , User, Version, and Virtualised. Detail and Description sounded possible, but yielded nowt. How do I filter for altbase.h?Bookstand
G
2

Check to see that both machines have the same versions of C++ Redistributable installed.

It is worth a shot, and will be easy to check.

screenshot

Girard answered 17/12, 2013 at 17:1 Comment(2)
They don't quite, but it's pretty close. I'll add a screenshot to the question.Bookstand
Visual C++ Redistributables don't contain ATL headers.Phosphorism

© 2022 - 2024 — McMap. All rights reserved.