问题
I am using the Windows Driver Kit (WinDDK 6001.18001) to build my userspace application rather than Visual Studio 2005. I am taking this approach because we also have to build driver components, so I'd prefer to have a single build environment to build everything. Microsoft itself uses this approach for several products.
This was working fine until I started using Boost 1.38.0. I'm not using C++ in the kernel mode components, just the userspace applications. In C++ code, it's natural to use the boost libraries. Unfortunately, the WDK doesn't agree.
The first error I noticed is that "#include <cstddef>" doesn't put ptrdiff_t
in the std namespace, as seems required by Annex D. Working around this left several errors in boost\lambda\detail\operator_return_type_traits.hpp
about error C2976: 'std::basic_string' : too few template arguments.
It appears redundant with iostream.
Has anyone successfully gotten the combination of Boost, iostream, and the WDK to work together?
My sources file:
TARGETNAME=foobar
TARGETTYPE=PROGRAM
USE_MSVCRT = 1
USE_STL = 1
USE_ATL = 1
ATL_VER = 30
STL_VER = 70
USE_NATIVE_EH = 1
USE_IOSTREAM = 1
SUBSYSTEM_VERSION = 5.02
C_DEFINES = \
-D_MT \
-DWIN_32 \
-DWIN32 \
-D_WINDOWS \
-DNT \
-D_WIN32_DCOM \
-DUNICODE \
-D_UNICODE \
-D_ATL_NO_DEBUG_CRT # because we are using USE_MSVCRT=1
SOURCES=service.cpp
INCLUDES=\
$(BOOST_INC_PATH)
TARGETLIBS=\
$(SDK_LIB_PATH)\ole32.lib \
$(SDK_LIB_PATH)\oleaut32.lib \
$(SDK_LIB_PATH)\uuid.lib \
UMTYPE=console
UMBASE=0x400000
service.cpp:
#include <iostream>
#include <cstddef>
namespace std {
typedef ::ptrdiff_t ptrdiff_t; // DDK C++ workaround
}
#include <boost/lambda/lambda.hpp>
int __cdecl main() {
return 0;
}
回答1:
Interesting question. Using STL as-is was a challenge in itself with the WDK. I have not ventured beyond. I can give this a try. Remember, the WDK has it's own compiler which is not the same as your VS2005/VS2008 complier (check the version numbers). It is highly likely there are a few bugs here and there.
Note, that USE_MSVCRT=1
and USE_STL=1
didn't gel well (at least for WDK 6001).
回答2:
Boost may already include a work-around for your issues, but isn't applying it because it doesn't recognise the compiler you're using (probably because drivers rarely use boost).
Try examining (and possibly editing) boost/config/select_compiler_config.hpp
and boost/config/compiler/visualc.hpp
to make sure the compiler workarounds for MSVC are enabled.
回答3:
I would suggest going different way, i.e compiling driver from VS200.x using this (ddkbuild) nice tool.
Being myself a command line person and using makefiles everywhere possible, i find build utility not useful for complex project.There is tons of limitation within MS build utility and i would recommend using VS environment for compiling your project.
I'm not sure if there is a howto in the ddkbuild, but it's straight forward to integrate ddkbuild.bat into VS custom build option.
来源:https://stackoverflow.com/questions/718309/using-boost-in-wdk-build-environment-for-applications