Visual Studio 8:混合模式程序集中的构建时间

发布于 2024-08-02 12:08:49 字数 815 浏览 3 评论 0原文

我有一个由大约 50 个源文件组成的 C++/CLI 程序集。该程序集中的代码静态链接到许多 C++ 库,以执行各种“繁重”类型的任务。

我正在使用 Visual Studio 8 (2005) SP1 来构建此程序集。

在一台像样的双核机器上,通过“仅项目”->“仅重建”构建此程序集(没有依赖项等)大约需要 4.5 分钟。下面是带有大约时间注释的简短构建输出:

Compiling...
(file 0)
(file 1)
...
(file N)                   // About 2 min total to compile all files
Linking...                 // About 12s
Generating Code            // 42s
Finished Generating Code   // < 1s
Embedding Manifest         // < 1s
Generating Code            // 30s
Finished Generating Code
(15 seconds of nothing)
Done

我应该如何开始调试为什么这个程序集需要这么长时间来构建?编译和链接时间虽然不是很好,但可能与我对这种规模的项目的期望差不多。让我担心的是,我看到两个“生成代码”步骤,每个步骤比大多数其他项目花费的时间要长得多。

我的第一个猜测是,这与链接到程序集中的非托管代码的数量有关。然而,我有几个托管应用程序项目使用同样多的本机代码,并且构建时间非常合理。

有谁知道到底是什么会导致两个“生成代码”步骤花费这么长时间?我是否缺少项目设置?

I have an C++/CLI assembly consisting of approximately 50 source files. The code in this assembly links statically to a number of C++ libraries to do various 'heavy-lifiting' type tasks.

I am using Visual Studio 8 (2005) SP1 to build this assembly.

Building just this assembly (without dependencies, etc) via 'Project Only'->'Rebuild Only' takes about 4.5 minutes on a decent dual-core machine. Below is the abbreviated build output annotated with approximate times:

Compiling...
(file 0)
(file 1)
...
(file N)                   // About 2 min total to compile all files
Linking...                 // About 12s
Generating Code            // 42s
Finished Generating Code   // < 1s
Embedding Manifest         // < 1s
Generating Code            // 30s
Finished Generating Code
(15 seconds of nothing)
Done

How should I begin debugging why this assembly is taking so long to build? The compile and link times, while not great, are probably about what I'd expect for a project of this size. What concerns me is the fact that I'm seeing two 'Generating Code' steps, each taking much longer than most other projects.

My first guess was that this has to do with the amount of unmanaged code that is linked into the assembly. However, I have several managed applications projects that use just as much native code, and the build times are very reasonable.

Does anyone know what exactly could cause two 'Generating Code' steps that take so long? Is there a project setting I'm missing?

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

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

发布评论

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

评论(1

已下线请稍等 2024-08-09 12:08:49

您的项目使用预编译头吗?托管 C++ 与非托管 C++ 一样支持它。要将项目切换到预编译标头:

请参阅 此文章(向下滚动到“预编译头”部分)了解详细信息。

  • 确保每个 .cpp 文件都以 #include "xxxx" 开头,其中 xxxx.h 是一些头文件,其中包含项目中使用的所有常见头文件。
  • 创建一个xxxx.cpp文件,只包含xxxx.h文件,没有其他代码
  • 在整个项目的VS编译设置中,对于所有配置(构建&发布),在pre -compile header 部分,使整个项目使用 xxxx.h 预编译头。
  • 仅在 xxxx.cpp 文件的 VS 编译设置中,对于所有配置(构建和发布),在预编译头部分中,将其设置为“生成预编译头”。

编译项目现在应该只需要之前构建时间的一小部分。

Do you use pre-compiled headers for your project? Managed C++ has support for it the same way unmanaged C++ does. To switch your project to pre-compiled headers:

See this article (scroll down to "Precompiled Header" section) for in-depth details.

  • Make sure that every single .cpp file begins with #include "xxxx", where xxxx.h is some header file that includes all the common header files used in your project.
  • Create an xxxx.cpp file that only includes the xxxx.h file, and has no other code
  • In the VS compile settings for the whole project, for all configurations (build & release), in the pre-compile header sections, make the whole project use the xxxx.h precompiled header.
  • In the VS compile settings for the xxxx.cpp file only, for all configurations (build & release), in the pre-compile header sections, set it to "generate precompiled header".

Compiling the project should now take a fraction of the previous build time.

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