[Qt-interest] qmake and customizing the target name of the library when using template "lib"

Oliver.Knoll at comit.ch Oliver.Knoll at comit.ch
Thu Feb 5 11:53:46 CET 2009


Ulrich Tuerk wrote on Thursday, February 05, 2009 11:34 AM:

> Hi all,
> I'm building shared libraries on Linux with qmake. The template is
> "lib". On the *nix systems it seems somehow hardcoded that the name
> of the library in the Makefile is set to
>
>         lib$(TARGET).so

By Unix library naming convention - the fact that you plan to use these libraries as "plugins" doesn't really matter - from a "Unix point of view" ;)

>
> where $(TARGET) is replaced by the variable TARGET from my .pro file.
>
> Can I somehow overwrite this? I would like define the resulting
> library name as those libraries are loadable (plugin-like) modules.
>
> I tried already to set QMAKE_TARGET in the .pro file as well, but

You could try to change the template to "plugin". But AFAICR this only omitted the version number in the library name. At least that was the case in Qt 3 times. So when I had for example:

template=lib
version=1.0.0
target=Foo

-> libFoo-1.0.0.so (and all the usual symbolic links like libFoo.so -> libFoo-1.0.so etc.)

template=plugin
version=1.0.0
target=Foo

-> libFoo.so (I think you still receive the lib-prefix though...)

The template "plugin" might have some other effects (compared to "lib"), but at that time (Qt 2 and later 3) I had my own platform-independent plugin-loader, which worked with either template (lib or plugin).

> this has no effect. Searching the files in the mkspecs directory
> didn't reveal anything useful.
>
> Changing directly the resulting Makefile before using it works but is
> not very convenient ;-)

Another workaround would be that you create a "custom target" which would e.g. copy all necessary files for distribution to a given place. And while doing so renaming your plugins as well. So when you enter:

%> make mydist

or something you'd execute a "cp project/plugins/MyPlugin/bin/libMyPlugin.so dist/wherever/bin/plugins/MyPlugin.so" etc.

Hmmm, to be honest I can't find the relevant documentation for Qt 4 qmake right now, but with Qt 3 qmake it was done like this:

http://doc.trolltech.com/3.3/qmake-manual-8.html#Customizing

Using QMAKE_EXTRA_UNIX_TARGETS (maybe that was dropped in Qt 4...)

Cheers, Oliver
--
Oliver Knoll
Dipl. Informatik-Ing. ETH
COMIT AG - ++41 79 520 95 22




More information about the Qt-interest-old mailing list