c++ - 无法打开包含文件 : 'atlbase.h' : No such file or directory

标签 c++ windows qt header-files sapi

<分区>

请看下面的代码

#define _ATL_APARTMENT_THREADED

#include <atlbase.h>
//You may derive a class from CComModule and use it if you want to override something,
//but do not change the name of _Module
extern CComModule _Module;
#include <atlcom.h>

#include <sapi.h>
#include <iostream>

using namespace std;

int main(int argc, char* argv[])
{
 cout << "Hello" << endl;
 ISpVoice * pVoice = NULL;

 if (FAILED(::CoInitialize(NULL)))
     return FALSE;

 HRESULT hr = CoCreateInstance(CLSID_SpVoice, NULL, CLSCTX_ALL, IID_ISpVoice, (void **)&pVoice);
 if( SUCCEEDED( hr ) )
 {
     cout << "Succeeded" << endl;
     hr = pVoice->Speak(L"Hello world", 0, NULL);
     pVoice->Release();
     pVoice = NULL;
 }
 else
 {
     cout << "Not succeeded" << endl;
 }

 ::CoUninitialize();
 return TRUE;
}

我正在使用 QT。当我运行这段代码时,出现错误

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

我注意到我的机器中没有文件 atlbase.hatlcom.h。然而,这段代码在我的笔记本电脑上运行没有错误,我在那里得到了那 2 个文件。

我正在考虑将这 2 个文件的拷贝复制到我的台式计算机中,它可以工作吗?如果是,我必须将它们复制到哪个文件夹?我是 Windows 编程、QT 和语音的新手。

最佳答案

对我而言,这些文件位于此处:

VS2010 - C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\include\atlbase.h
VS2008 - C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\atlmfc\include\atlbase.h

请注意 ATL 是 Microsoft Visual Studio 的一部分(但不是 Express Edition)。 如果您需要为 Express 获取 ATL,请查看此主题 How to add WTL and ATL to visual studio c++ express 2008

我认为复制 atlbase.hatlcom.h 对您没有帮助。 您可能会尝试获取所有 atl*.h 文件并安装所需的 Microsoft Visual C++ Redistributable 包。

关于c++ - 无法打开包含文件 : 'atlbase.h' : No such file or directory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16404092/

相关文章:

c++ - 为什么 static_cast(*this) 到基类会创建一个临时拷贝?

c++ - 合并排序导致堆栈溢出?

windows - 启用 Windows 命令行历史记录

c++ - 使用 QML (Qt 5) 导出 QFlags - staticMetaObject 错误

c++ - Qt去掉标题栏

c++ - 提高 TM 模拟器的性能

远程 MS Windows 主机上的 Python 子进程

windows - "Neutral"、 "Neutral(Default)"和 "Neutral(Sys. Default)"之间的区别?

c++ - 如何使用 QList 跟踪子类的实例

windows - 在没有硬件加速的情况下在 Windows 上部署 Qt5