为什么库名的名称会额外增加0? [英] Why library name gets an additional 0 in its name?

查看:144
本文介绍了为什么库名的名称会额外增加0?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个很小的Qt项目,其项目文件如下:

I have this tiny Qt project with a project file like this:

TEMPLATE = lib
TARGET = record32
VERSION = 0.0.1
DEPENDPATH += .
INCLUDEPATH += .

CONFIG += shared
SOURCES += recorder.cpp
HEADERS += recorder.h

当我用qmake && nmake从它编译一个库时,它会变成文件

When I compile a library from it by qmake && nmake, it results into files

record32.obj
record320.lib
record320.dll
...

为什么在lib和dll名称中又添加了0?

生成的makefile似乎不是在附加它,而只是假设它在Makefile.Release中,它只是说:

The generated makefiles seem not be appending it but rather just assume it, in Makefile.Release it just says:

####### Files

SOURCES       = recorder.cpp release\moc_recorder.cpp
OBJECTS       = release\recorder.obj release\moc_recorder.obj
DIST          = 
QMAKE_TARGET  = recorder
DESTDIR        = release\ #avoid trailing-slash linebreak
TARGET         = record320.dll
DESTDIR_TARGET = release\record320.dll

如何防止出现这种情况并根据需要命名我的图书馆?

(请注意,手动修复makefile.release不是可行的解决方案)

(Note that manually fix the makefile.release isn't a accetable solution)

推荐答案

它来自VERSION的第一部分. "lib" TEMPLATE正在添加它.

It comes from the first part of VERSION. The "lib" TEMPLATE is adding it.

IMO最好将它包含在库名称中,因为它避免了在Windows中发生的臭名昭著的"DLL Hell"(在该约定中未始终遵循该约定)...通过命名库文件以包含主要版本号,用户可以安装多个版本,并且程序在运行时将使用正确的版本. DLL版本不必一定要与整个项目发行版本相同.在Linux和OSX上,版本会附加到文件名(例如librecorder.so.0.0.1)

IMO it's a good idea to include it in the library name, since it avoids the infamous "DLL Hell" that happens on Windows where this convention is not followed consistently... By naming the library files to include the major version number, users can have multiple versions installed and programs will use the correct versions at run time. The DLL version doesn't neccesarily need to be the same as the overall project release version. On Linux and OSX the versions are appended to the filename (e.g. librecorder.so.0.0.1)

[如果使用Visual C ++,我也总是添加一个标签,指示我使用的Visual C版本,因为不同版本生成的代码在很大程度上也不兼容.]

[If using Visual C++ I also always add a tag indicating what version of Visual C I used since code generated by the different versions are largely incompatible also.]

也许您可以省略VERSION的定义以禁用此行为,但是我现在无法验证Windows(在Linux上,共享库始终具有版本号,仅假定版本为1.0.0.)

Maybe you can just omit the definition of VERSION to disable this behavior, but I can't verify that right now for Windows (On Linux, where shared libraries always have version numbers, it just assumes version 1.0.0.)

这篇关于为什么库名的名称会额外增加0?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆