在 WDK 构建环境中使用 boost 来构建应用程序?

发布于 2024-07-16 14:30:58 字数 1457 浏览 6 评论 0原文

我使用 Windows 驱动程序工具包 (WinDDK 6001.18001) 来构建我的用户空间应用程序,而不是 Visual Studio 2005。我采用这种方法是因为我们还必须构建驱动程序组件,所以我更喜欢有一个构建环境来构建所有内容。 微软本身在多种产品中使用了这种方法。

在我开始使用 Boost 1.38.0 之前,这一切都运行良好。 我不在内核模式组件中使用 C++,而只是在用户空间应用程序中使用。 在 C++ 代码中,使用 boost 库是很自然的。 不幸的是,WDK 并不同意。

我注意到的第一个错误是“#include” 没有将 ptrdiff_t 放入 std 命名空间,正如附件 D 所要求的那样。解决此问题在 boost\lambda\detail\operator_return_type_traits.hpp 中留下了几个关于 的错误>错误 C2976:'std::basic_string':模板参数太少。 它对于 iostream 来说显得多余。

有人成功地将 Boost、iostream 和 WDK 结合起来一起工作吗?

我的源文件:

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

鸩远一方 2024-07-23 14:30:59

Boost 可能已经包含了针对您的问题的解决方法,但没有应用它,因为它无法识别您正在使用的编译器(可能是因为驱动程序很少使用 boost)。

尝试检查(并可能编辑)boost/config/select_compiler_config.hppboost/config/compiler/visualc.hpp 以确保启用 MSVC 的编译器解决方法。

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.

成熟稳重的好男人 2024-07-23 14:30:59

我建议采用不同的方式,即使用 this 从 VS200.x 编译驱动程序(ddkbuild) 不错的工具。

我自己是一个命令行人,并且在任何可能的地方使用 makefile,我发现构建实用程序对于复杂的项目没有用。MS 构建实用程序中有很多限制,我建议使用 VS 环境来编译您的项目。

我不确定 ddkbuild 中是否有说明,但将 ddkbuild.bat 集成到 VS 自定义构建选项中是很直接的。

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.

吹泡泡o 2024-07-23 14:30:58

有趣的问题。 对于 WDK,按原样使用 STL 本身就是一个挑战。 我还没有冒险超越。 我可以尝试一下。 请记住,WDK 有自己的编译器,该编译器与您的 VS2005/VS2008 编译器不同(检查版本号)。 很可能到处都存在一些错误。

请注意,USE_MSVCRT=1USE_STL=1 没有很好地结合在一起(至少对于 WDK 6001 而言)。

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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文