Why does the library name get an extra 0 on its behalf?

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 qmake && nmake

, it is output to files

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

      

Why is the extra 0 being added to the lib and dll names?

The generated makefiles don't seem to add it, but just assume that in Makefile.Release

it 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 call my libraries as I want?

(Note that manually fixing makefile.release is not a suitable solution)

+2


source to share


3 answers


This comes from the first part of VERSION. "Lib" TEMPLATE adds it.

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



[When using Visual C ++, I also always add a tag to indicate which version of Visual C I was using, since the code generated by the different versions is also incompatible.]

Perhaps you can just omit the VERSION definition 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.)

+6


source


Try the following:



CONFIG += skip_target_version_ext

      

+3


source


Helpful trick :

VERSION = 0.0.1
win32:TARGET_EXT = .dll

      

With this you get:

  • on Linux: librecord.so, ..., librecord.so.0.0.1
  • on Windows: record.dll
+1


source







All Articles