【问题标题】:How to not create .lib and .exp files in Visual C++ .exe project如何不在 Visual C++ .exe 项目中创建 .lib 和 .exp 文件
【发布时间】:2015-08-06 14:49:14
【问题描述】:

当我在 Visual Studio 中使用 .exe 输出构建我的 C++ 项目时,它会为我的项目创建一个 .lib 和 .exp 文件,这需要很长时间。我在 stdafx.h(预编译头文件)的开头添加了 _DO_NOT_EXPORT 条件以尝试跳过此步骤,但它仍会在每次构建结束时创建 .lib 和 .exp 文件。我是否在正确的地方添加了条件?

【问题讨论】:

  • 您必须在源代码中找到__declspec(dllexport) 属性,并采取一切必要措施确保编译器看不到它。这并不总是实用的,它可能不是你的代码。然后你就说“aw shucks”。
  • @HansPassant 我相信 __declspec(dllexport) 属性是在我包含在 stdafx.h 中的 boost 库中的某处定义的,所以如果我在这种情况下理解正确,就没有办法禁用 dllexport 吗?跨度>
  • boost 的一些库(如 Thread)只能动态链接,但它们中的大多数不应该自动执行 dllimport(更不用说 dllexport)了。

标签: c++ build .lib


【解决方案1】:

为了它的价值,你可以禁用该块

#if defined(BOOST_HAS_DECLSPEC) && !defined(__COMO__)
# if defined(__BORLANDC__)
# define BOOST_DLLEXPORT __export
# else
# define BOOST_DLLEXPORT __declspec(dllexport)
# endif
#elif ! defined(_WIN32) && ! defined(_WIN64)
# if defined(__MWERKS__)
# define BOOST_DLLEXPORT __declspec(dllexport)
# elif defined(__GNUC__) && (__GNUC__ >= 3)
# define BOOST_USED __attribute__ ((used))
# elif defined(__INTEL_COMPILER) && (BOOST_INTEL_CXX_VERSION >= 800)
# define BOOST_USED __attribute__ ((used))
# endif
#endif

serialization/force_include.hpp 的 Boost 中。

参考:http://lists.boost.org/boost-users/2008/06/37175.php

【讨论】:

    猜你喜欢
    • 2011-02-18
    • 2011-02-09
    • 1970-01-01
    • 1970-01-01
    • 2015-02-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多