views:

137

answers:

1

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)

+3  A: 

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.)

Reed Hedges
I tested it and yes, commenting out version makes the 0 go away. You also gave good reasoning why it is there, so maybe its not that bad thing besides it only uses major version, the name isn't changing between 0.0.1 to 0.9.9 at all and thus, the "DLL hell" might just as well happen.. Thanks!
Tuminoid