While I agree its a well established scheme on *nix systems to prefix with "lib", it should not be forced on you. If there is a legitimate need to have a library be named a certain way based on project need, you should be able to do that. Knowing that qmake forces that, I can work around it . . . mainly for project use of loading library at runtime with QLibrary.
It also seems that qmake will use the VERSION on a windows build to tack on a version major number to the library name. I had to work around that as well . . . good thing that if you leave it blank it will not generate one on its own.
So now I have the following in my .pro file to build the same name across my platforms [linux/mac/windows], all with lib- prefix:
win32 {
TARGET = lib$$qtLibraryTarget($$TARGET)
} else {
TARGET = $$qtLibraryTarget($$TARGET)
VERSION = $$system(awk \'/const VERSION/ { print substr( $6, 3 ) }\' main.cpp)
# clean up shared libs as version number changes
QMAKE_DISTCLEAN += *.so*
}
TEMPLATE = lib
win32 {
TARGET = lib$$qtLibraryTarget($$TARGET)
} else {
TARGET = $$qtLibraryTarget($$TARGET)
VERSION = $$system(awk \'/const VERSION/ { print substr( $6, 3 ) }\' main.cpp)
# clean up shared libs as version number changes
QMAKE_DISTCLEAN += *.so*
}
TEMPLATE = lib
To copy to clipboard, switch view to plain text mode
The only ugliness that I have seen from this is that in a mingw build on windows, there is a temporary library .a that is created before making the .dll that qmake forces to have a lib prefix, so the temp name is liblibNAME.a. Since it is temp, I am not worrying to much about that.
My description was for a simple case. Eventually the name will be changed so the #if method will not work. I guess I could have subclassed QLibrary to try additional prefixes, but this seems to work for now.
Bookmarks