Visual Studio 8:混合模式程序集中的构建时间
我有一个由大约 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的项目使用预编译头吗?托管 C++ 与非托管 C++ 一样支持它。要将项目切换到预编译标头:
请参阅 此文章(向下滚动到“预编译头”部分)了解详细信息。
xxxx.h
是一些头文件,其中包含项目中使用的所有常见头文件。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.
xxxx.h
is some header file that includes all the common header files used in your project.xxxx.h
file, and has no other codexxxx.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.