为什么库名称中会多一个 0?
我有一个带有这样的项目文件的小型 Qt 项目:
TEMPLATE = lib
TARGET = record32
VERSION = 0.0.1
DEPENDPATH += .
INCLUDEPATH += .
CONFIG += shared
SOURCES += recorder.cpp
HEADERS += recorder.h
当我通过 qmake && 从中编译一个库时 nmake,它会生成文件
record32.obj
record320.lib
record320.dll
...
为什么在 lib 和 dll 名称中添加额外的 0?
生成的 makefile 似乎没有附加它,而只是在 Makefile 中假设它。 Release
它只是说:
####### 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 不是一个可接受的解决方案)
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
When I compile a library from it by qmake && nmake
, it results into files
record32.obj
record320.lib
record320.dll
...
Why is that additional 0 added to the lib and dll names?
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
How can I prevent it and name my libraries as I wish?
(Note that manually fix the makefile.release isn't a accetable solution)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
它来自VERSION的第一部分。 “lib”模板正在添加它。
IMO 将其包含在库名称中是一个好主意,因为它避免了 Windows 上发生的臭名昭著的“DLL Hell”,其中未一致遵循此约定...通过命名库文件以包含主版本号,用户可以安装了多个版本,程序将在运行时使用正确的版本。 DLL 版本不一定需要与整个项目发布版本相同。 在 Linux 和 OSX 上,版本附加到文件名(例如 librecorder.so.0.0.1)
[如果使用 Visual C++,我也总是添加一个标记,指示使用的 Visual CI 版本,因为不同版本生成的代码在很大程度上也不兼容.]
也许你可以省略 VERSION 的定义来禁用此行为,但我现在无法在 Windows 上验证这一点(在 Linux 上,共享库总是有版本号,它只是假设版本为 1.0.0。)
It comes from the first part of VERSION. The "lib" TEMPLATE is adding it.
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)
[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.]
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.)
尝试这个:
Try this:
有用的技巧:
有了这个,你将得到:
Useful trick:
With this you will get: