9

如何阻止 Qt 将我的 DLL 重命名为MyDLLName{MAJOR_VERSION_NUM}.dll?

这只发生在我VERSION在项目文件中设置时,但我也想设置版本。例如,如果我有:

VERSION = 1.2.3.4

我的库被命名MyDll,它将在调试文件夹中创建我的 DLL 作为MyDLL1.dll. 如果我拿走版本号,它会保留我想要的名称(MyDLL.dll)。

谢谢。

4

2 回答 2

14

用这个:

CONFIG += skip_target_version_ext
于 2015-12-26T10:16:27.613 回答
6

See this answer (on SO) for why it is there: Why library name gets an additional 0 in its name?

You can "not-set" the version to remove it from the generated name, but are you sure you want to do that? (It's there to avoid DLL Hell.)

The "proper-answer" is that the LIB template is adding the version number.

Also, note:

  • VERSION is used to define VER_MAJ and VER_MIN
  • msvc_nmake generator adds /VERSION:major.minor to link flags if !empty
  • msvc_vcproj generate adds /VERSION:major.minor to link flags and MSVCPROJ_VERSION if !empty

You can explicitly set those yourself, or "unset" any of them.

You can explicitly remove the version number from the target name with the TARGET_EXT variable, for example, see: http://qt-project.org/faq/answer/how_can_i_add_version_information_to_my_application

If you want to create your own plugin to decide how to generate the target name (without the version number), you can make your own plugin as described in this answer (on SO): How to avoid having version numbers in .so file name

于 2013-02-10T16:04:58.233 回答