Cannot open include file: 'atlbase.h': no โ€‹โ€‹such file or directory

Please take a look at the following code

#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; } 

I am using QT. When I run this code, I get an error

Cannot open include file: 'atlbase.h': no โ€‹โ€‹such file or directory

I noticed that I do not have atlbase.h or atlcom.h on my machine. However, this code works without errors on my laptop, and I got these 2 files.

I'm considering getting a copy of these two files on my desktop computer, and will it work? If so, in which folder should I copy them? I am new to Windows programming, QT and speech.

+9
source share
5 answers

For me, these files are here:

 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 

Please note that ATL is part of Microsoft Visual Studio (but not Express Edition). If you need to get ATL for Express, please take a look at this topic. How to add WTL and ATL in visual studio C ++ express 2008

I don't think copying atlbase.h and atlcom.h will help you. You can try to get all the atl * .h files and install the required Microsoft Visual C ++ Redistributable package.

+12
source

You do not need these headers for this code. Remove extern CComModule _Module; and atl headers. Add #include <windows.h> .

+6
source

Having headers is certainly a step in the right direction, but you will also need libraries to compile (if everything is not implemented in the headers). You can place the headers wherever you want, just make sure the linker finds them (either in the default location *, or by including the path as a flag).

* I do not know the default location for Windows.

+1
source

I installed VS 2015 Express, which said it was the VS 2017 community when it started, and had this problem with altbase.h with very simple C ++ programs. You can commit to receiving accurate include files, or you can take a step back to solve this problem. Microsoft is a large, thorough company, when they give you the C ++ compiler, they give you the libraries you need. When I fixed this problem, I

  • launched Visual Studio as an administrator.
  • Win32 C ++ Console Application Created
  • I did NOT check the "Empty project" on the C ++ project creation wizard.
  • Did NOT check common header files for ATL and MFC.

Then, when I added my code, the generated stdafx.h header, enabled by default, did not cause this altbase.h problem, as it did before. I was able to add other functions and did "using namespace std;" and I was able to do cout and cin's. My base operating system is Windows 7 Home Premium. Obviously, when installing VS 2015/2017 Express, you had to set the C ++ checkbox to install.

+1
source

ATL and MFC come with retail versions of VC ++. It doesn't matter where you put the included libraries (atl * .lib). Just specify the correct paths to them in the IDE.

0
source

All Articles