Visual Studio 2010 违背我的意愿创建静态库

发布于 2024-12-01 07:18:10 字数 144 浏览 1 评论 0原文

我最近继承了一个我已经清理并完成的项目。然而,有一个恼人的问题一直困扰着我。每当我构建它时,它都会在 *.exe 旁边创建一个静态库(*.lib + *.exp 文件)。 *.lib 文件是不必要的。我一生都找不到在设置中关闭此功能的位置。构建它并没有什么坏处,只是很烦人。

I recently inherited a project which I've cleaned up and finished. However, there is one annoying issue that is just bugging the heck out of me. Whenever I build it, it creates a static library (*.lib + *.exp files) alongside the *.exe. The *.lib file is unnecessary. I can't for the life of me find where in the settings to turn this off. It doesn't hurt anything to build it, it's just annoying.

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

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

发布评论

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

评论(2

作死小能手 2024-12-08 07:18:10

我也有同样的问题,而且我是一个非常迂腐的人,所以我介意。所以我

dumpbin /EXPORTS the_naughty_file.lib

在不需要的 .lib 文件上使用了它,它显示:

Microsoft (R) COFF/PE Dumper Version 9.00.21022.08
Copyright (C) Microsoft Corporation.  All rights reserved.

Dump of file E:\my-projects\Robotics\SLAM_plus_plus\bin\Release\SLAM_plus_plus6.lib

File Type: LIBRARY

     Exports

       ordinal    name

                  ??4_Init_locks@std@@QAEAAV01@ABV01@@Z (public: class std::_Init_locks & __thiscall std::_Init_locks::operator=(class std::_Init_locks const &))

  Summary

      DB .debug$S
      14 .idata$2
      14 .idata$3
       4 .idata$4
       4 .idata$5
      14 .idata$6

经过一段时间的谷歌搜索,我发现了 post,解释这是一个自动生成的函数,仅在以下情况下生成使用动态链接的运行时库(静态不会这样做)。

要解决此问题,请转到项目属性 > C++ > > 预处理器,并添加:

_STATIC_CPPLIB

或转到项目属性 > C++ > > 代码生成并将运行时库更改为多线程(MT)

烦人的文件现在消失了,是的:)。不过,已在 Visual Studio 2008 中进行了测试。但如果它不起作用,只需在 .lib 上使用 dumpbin /EXPORTS 来跟踪导出并将其发布到此处。

I had the same problem, and since I'm a very pedantic person, I mind. So I used

dumpbin /EXPORTS the_naughty_file.lib

On the unwanted .lib file, and it reveals:

Microsoft (R) COFF/PE Dumper Version 9.00.21022.08
Copyright (C) Microsoft Corporation.  All rights reserved.

Dump of file E:\my-projects\Robotics\SLAM_plus_plus\bin\Release\SLAM_plus_plus6.lib

File Type: LIBRARY

     Exports

       ordinal    name

                  ??4_Init_locks@std@@QAEAAV01@ABV01@@Z (public: class std::_Init_locks & __thiscall std::_Init_locks::operator=(class std::_Init_locks const &))

  Summary

      DB .debug$S
      14 .idata$2
      14 .idata$3
       4 .idata$4
       4 .idata$5
      14 .idata$6

And after a while of googling, I found a post, explaining this is an automatically generated function, which is only generated when using dynamically-linked runtime library (static doesn't do that).

To fix the problem, either go to Project Properties > C ++ > Preprocessor, and add:

_STATIC_CPPLIB

Or go to Project Properties > C ++ > Code Generation and change Runtime Library to Multithreaded (MT).

The annoying files are now gone, yay :). Tested in Visual Studio 2008, though. But if it doesn't work, just use dumpbin /EXPORTS on the .lib to trace exports and post them here.

多像笑话 2024-12-08 07:18:10

项目被指定为静态库,或者解决方案中有一个项目是静态库。

Either the project is designated as a static library or there is a project in the solution that is a static library.

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