如何正确包含atlbase.h

时间:2014-02-16 03:10:15

标签: c++ visual-studio-2012 openframeworks

我正在尝试使用一些提供给我的库代码,这些代码需要一些ATL功能,但我一直会遇到如下错误:

1>c:\program files (x86)\microsoft visual studio 11.0\vc\atlmfc\include\atltransactionmanager.h(396): error C2039: 'CreateFile' : is not a member of '`global namespace''
1>c:\program files (x86)\microsoft visual studio 11.0\vc\atlmfc\include\atltransactionmanager.h(427): error C2039: 'DeleteFile' : is not a member of '`global namespace''
1>c:\program files (x86)\microsoft visual studio 11.0\vc\atlmfc\include\atltransactionmanager.h(460): error C2039: 'MoveFile' : is not a member of '`global namespace''
1>c:\program files (x86)\microsoft visual studio 11.0\vc\atlmfc\include\atlbase.h(6517): error C2039: 'GetModuleFileName' : is not a member of '`global namespace''
1>c:\program files (x86)\microsoft visual studio 11.0\vc\atlmfc\include\atlbase.h(6517): error C3861: 'GetModuleFileName': identifier not found
1>c:\program files (x86)\microsoft visual studio 11.0\vc\atlmfc\include\atlbase.h(6591): error C2039: 'GetModuleFileName' : is not a member of '`global namespace''
1>c:\program files (x86)\microsoft visual studio 11.0\vc\atlmfc\include\atlbase.h(6591): error C3861: 'GetModuleFileName': identifier not found
1>c:\program files (x86)\microsoft visual studio 11.0\vc\atlmfc\include\statreg.h(481): error C3861: 'FindResource': identifier not found
1>c:\program files (x86)\microsoft visual studio 11.0\vc\atlmfc\include\statreg.h(674): error C3861: 'CreateFile': identifier not found
1>c:\program files (x86)\microsoft visual studio 11.0\vc\atlmfc\include\atlbase.h(6676): error C3861: 'GetModuleFileName': identifier not found
1>c:\program files (x86)\microsoft visual studio 11.0\vc\atlmfc\include\atlbase.h(6762): error C3861: 'GetModuleFileName': identifier not found
1>c:\program files (x86)\microsoft visual studio 11.0\vc\atlmfc\include\atlbase.h(6885): error C3861: 'GetModuleFileName': identifier not found
1>c:\program files (x86)\microsoft visual studio 11.0\vc\atlmfc\include\atlbase.h(7228): error C3861: 'GetModuleFileName': identifier not found
1>c:\program files (x86)\microsoft sdks\speech\v11.0\include\sphelper.h(1246): error C2039: 'LoadLibrary' : is not a member of '`global namespace''
1>c:\program files (x86)\microsoft sdks\speech\v11.0\include\sphelper.h(1246): error C3861: 'LoadLibrary': identifier not found

我确实将它安装在我自己的机器上,原始项目本身编译没有问题。出于保密原因,我无法共享原始项目本身,但我可以共享其编译标志(对于格式不佳的道歉):

/Yc"stdafx.h" /GS /analyze- /W3 /wd"4995" /Zc:wchar_t /ZI /Gm /Od /Fd"Debug\vc110.pdb" /fp:precise /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_USRDLL" /D "DLL_EXPORTS" /D "_WINDLL" /D "_UNICODE" /D "UNICODE" /errorReport:prompt /WX- /Zc:forScope /RTC1 /Gd /Oy- /MDd /Fa"Debug\" /EHsc /nologo /Fo"Debug\" /Fp"Debug\KinectCommonBridge.pch" 

这是我的(我可以随意忽略openFrameworks相关的包含,我试图让项目尽可能接近他们的设置,以便它更容易为用户翻译):

/Yc"stdafx.h" /GS /TP /analyze- /W3 /Zc:wchar_t /I"..\..\..\libs\openFrameworks" /I"..\..\..\libs\openFrameworks\graphics" /I"..\..\..\libs\openFrameworks\app" /I"..\..\..\libs\openFrameworks\sound" /I"..\..\..\libs\openFrameworks\utils" /I"..\..\..\libs\openFrameworks\communication" /I"..\..\..\libs\openFrameworks\video" /I"..\..\..\libs\openFrameworks\types" /I"..\..\..\libs\openFrameworks\math" /I"..\..\..\libs\openFrameworks\3d" /I"..\..\..\libs\openFrameworks\gl" /I"..\..\..\libs\openFrameworks\events" /I"..\..\..\libs\glut\include" /I"..\..\..\libs\rtAudio\include" /I"..\..\..\libs\quicktime\include" /I"..\..\..\libs\freetype\include" /I"..\..\..\libs\freetype\include\freetype2" /I"..\..\..\libs\freeImage\include" /I"..\..\..\libs\fmodex\include" /I"..\..\..\libs\videoInput\include" /I"..\..\..\libs\glew\include\" /I"..\..\..\libs\glu\include" /I"..\..\..\libs\tess2\include" /I"..\..\..\libs\cairo\include\cairo" /I"..\..\..\libs\poco\include" /I"..\..\..\libs\glfw\include" /I"..\..\..\libs\openssl\include" /I"..\..\..\addons" /I"src" /I"..\..\..\addons\ofxKinectCommonBridge\src" /I"..\..\..\addons\ofxKinectCommonBridge\libs\KinectCommonBridge\include" /I"..\..\..\addons\ofxGui\src" /I"C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\atlmfc\include" /ZI /Gm /Od /Fd"obj\Debug\vc110.pdb" /fp:precise /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "POCO_STATIC" /D "CAIRO_WIN32_STATIC_BUILD" /D "DISABLE_SOME_FLOATING_POINT" /D "_UNICODE" /D "UNICODE" /errorReport:prompt /WX- /Zc:forScope /RTC1 /Gd /Oy- /MDd /Fa"obj\Debug\" /EHsc /nologo /Fo"obj\Debug\" /Fp"obj\Debug\SpeechExample_debug.pch" 

我对ATL或它的使用不是很熟悉,但在我看来,正确地包含这个文件并不困难。我已经挖掘了两个项目,并且在任何包含或编译器标志中找不到任何根本不同的东西。感谢您提供任何指导,如果有帮助,我很乐意提供更多信息。

1 个答案:

答案 0 :(得分:2)

::CreateFileWinBase.h中定义。因此,在包含 atlbase.h 之前,您应该#include WinBase.hWindows.h

我无法确定为什么在 atlbase.h 本身没有这样做。但您可以定义项目中使用的Windows头文件。