找不到 C++ #include <atlbase.h>
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3898287/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
C++ #include <atlbase.h> is not found
提问by Ramilol
When I compile my C++ program in Visual Studio Express it says that it can't find atlbase.h
. Am I missing some SDK or something?
当我在 Visual Studio Express 中编译我的 C++ 程序时,它说它找不到atlbase.h
. 我错过了一些 SDK 还是什么?
采纳答案by wkl
Microsoft ATL (Active Template Library), which includes the header atlbase.h
is included with the Windows 2003 SDK, but it is not included with any newer Windows SDK release. It is also included with Professional editions of Visual Studio.
Microsoft ATL(活动模板库),其中包含标头atlbase.h
,包含在Windows 2003 SDK 中,但不包含在任何较新的 Windows SDK 版本中。它也包含在 Visual Studio 的专业版中。
回答by KymikoLoco
回答by Bernhard Wally
It is included with the Windows Driver Kit Version 7.1.0.
回答by user145400
For users of Visual Studio 2015, ensure Common Tools for C++ is installed (part of the VS installer).
对于 Visual Studio 2015 的用户,请确保安装了 Common Tools for C++(VS 安装程序的一部分)。
回答by pogosama
Solution for Visual Studio 2017 Express edition
Visual Studio 2017 Express 版解决方案
I had the same error when building a COM C++ project in Visual Studio 2017 Express edition. As mentioned by several users here, ATL support is not included with the Express edition of Visual Studio. So to build a C++ COM/ATL project you need at least the Community edition.
在 Visual Studio 2017 Express 版本中构建 COM C++ 项目时,我遇到了同样的错误。正如这里的几个用户所提到的,ATL 支持不包含在 Visual Studio 的 Express 版本中。因此,要构建 C++ COM/ATL 项目,您至少需要社区版.
If you really need to use the Express edition, you can download and install the Build Tools for Visual Studio 2017. Make sure to enable the 'Visual C++ ATL for x86 and x64' component during the setup.
如果确实需要使用 Express 版,可以下载安装Visual Studio 2017 构建工具。确保在安装过程中启用“ Visual C++ ATL for x86 and x64”组件。
After that add additional VC++ directories in the project properties:
之后在项目属性中添加额外的 VC++ 目录:
- Include directories:
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.14.26428\atlmfc\include
- Library directories:
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.14.26428\atlmfc\lib\x86
- 包括目录:
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.14.26428\atlmfc\include
- 库目录:
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.14.26428\atlmfc\lib\x86
The VC++ compiler should now be able to find the ATL source and library files.
VC++ 编译器现在应该能够找到 ATL 源文件和库文件。
回答by Froggy
Situation
情况
With Visual Studio 2017 Community Edition, we installed "Visual C++ ATL support" and MFC and ATL support. The error still occurred in our x64 project.
在 Visual Studio 2017 社区版中,我们安装了“Visual C++ ATL 支持”以及 MFC 和 ATL 支持。在我们的 x64 项目中仍然发生错误。
Solution
解决方案
We fixed some paths with the following two commands:
我们使用以下两个命令修复了一些路径:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC>mklink /d atlmfc "C:\Program Files (x86)\Microsoft Visual Studio17\Community\VC\Tools\MSVC.11.25503\atlmfc"
C:\Program Files (x86)\Microsoft Visual Studio17\Community\VC\Tools\MSVC.11.25503\atlmfc\lib>mklink /d amd64 "C:\Program Files (x86)\Microsoft Visual Studio17\Community\VC\Tools\MSVC.11.25503\atlmfc\lib\x64
Details
细节
We eventually found the header atlbase.h
in C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\atlmfc\include
. This path simply was not added to the VC Include directory by vsvars32.bat
, so the header was not found during build.
我们最终atlbase.h
在C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\atlmfc\include
. 这个路径根本没有被添加到 VC Include 目录中vsvars32.bat
,所以在构建过程中没有找到头文件。
vsvars32.bat includes the following line:
vsvars32.bat 包括以下行:
@if exist "%VCINSTALLDIR%ATLMFC\INCLUDE" set INCLUDE=%VCINSTALLDIR%ATLMFC\INCLUDE;%INCLUDE%`.
This resolved to C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\atlmfc\include
in our machine.
这C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\atlmfc\include
在我们的机器上解决了。
We created a directory junction, so the build tool finds atlbase.h
in the expected directory (this is the first command from the Solution section above):
我们创建了一个目录连接,所以构建工具会atlbase.h
在预期的目录中找到(这是上面解决方案部分的第一个命令):
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC>mklink /d atlmfc "C:\Program Files (x86)\Microsoft Visual Studio17\Community\VC\Tools\MSVC.11.25503\atlmfc"
Afterwards, the linker did not find atls.lib
(see Cannot Open File atls.lib). This was due to the expected file structure was that lib
should directly contain the x86 version of the libs and lib\amd64
should contain the x64 variants. Instead, lib\x86
contained the x86 versions and lib\x64
contained the 64 bit versions. Since we build a 64 bit project, creating another directory junk from amd64 to x64 solved the problem:
之后,链接器没有找到atls.lib
(请参阅无法打开文件 atls.lib)。这是由于预期的文件结构lib
应该直接包含库的 x86 版本并且lib\amd64
应该包含 x64 变体。相反,lib\x86
包含 x86 版本和lib\x64
64 位版本。由于我们构建了一个64位的项目,再创建一个从amd64到x64的目录垃圾就解决了这个问题:
C:\Program Files (x86)\Microsoft Visual Studio17\Community\VC\Tools\MSVC.11.25503\atlmfc\lib>mklink /d amd64 "C:\Program Files (x86)\Microsoft Visual Studio17\Community\VC\Tools\MSVC.11.25503\atlmfc\lib\x64
回答by Drew Dormann
That appears to be a part of the Windows Platform SDK.
这似乎是Windows Platform SDK的一部分。
You should search your computer for the file. That will tell you if you're missing it.
您应该在计算机中搜索该文件。这会告诉你是否遗漏了它。
回答by user2117423
I had same problem with sample project. I specified the sample project's properties and the sample project compiled successfully.
我对示例项目有同样的问题。我指定了示例项目的属性并且示例项目编译成功。
Visual Studio 8
For headerC:\Program Files\Microsoft Visual Studio 8\VC\atlmfc\include
Visual Studio 8
对于标题C:\Program Files\Microsoft Visual Studio 8\VC\atlmfc\include
For .lib
fileC:\Program Files\Microsoft Visual Studio 8\VC\atlmfc\lib
对于.lib
文件C:\Program Files\Microsoft Visual Studio 8\VC\atlmfc\lib
回答by Marty
I have not yet seen anyone mention Visual Studio 2015 (MSBuild 14.0). In this case I've had to download Visual C++ BuildTools (found here: https://visualstudio.microsoft.com/vs/older-downloads/). After having installed this, running the installer again allowed me to modify the installation and include the ATL libs.
我还没有看到有人提到 Visual Studio 2015 (MSBuild 14.0)。在这种情况下,我必须下载 Visual C++ BuildTools(在此处找到:https://visualstudio.microsoft.com/vs/older-downloads/ )。安装后,再次运行安装程序允许我修改安装并包含 ATL 库。
Hope this helps anyone that is still using MSBuild 14.0
希望这对仍在使用 MSBuild 14.0 的人有所帮助