Results 1 to 4 of 4

Thread: qmake and library version handling

  1. #1
    Join Date
    Feb 2008
    Posts
    26
    Thanks
    5
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default qmake and library version handling

    Hi,

    I've the following .pro file to compile a library called "mylib" :

    Qt Code:
    1. TEMPLATE = lib
    2. VERSION = 0.1
    3. TARGET = mylib
    4. ...
    To copy to clipboard, switch view to plain text mode 

    When compiling under windows with QtCreator (mingw), it generates a file named "mylib0.dll" (and a "mylib0.a"). Now, if I compile under linux with g++, I got "mylib.so -> mylib.so.0 -> mylib.so.0.1-> mylib.so.0.1.0".

    When I tried to use the library from another .pro files, I do:
    Qt Code:
    1. TEMPLATE = app
    2. TARGET = test
    3. LIBS += -L ../mylib -lmylib
    4. INCLUDEPATH += ../mylib/include
    5. ...
    To copy to clipboard, switch view to plain text mode 

    It works under linux, as the linker search for a "mylib.so" file, but It is not working under windows. If I change "-lmylib" with "-lmylib0", it works under windows but not under linux (as the file is called "mylib.so.0".

    How can I handle this ? I'm trying to find a solution which avoid specifying as much as possible scopes. This is because I want to support a lot of platform and do not want, in each of my pro files, making win32 {..}, unix {...}, mingw {...} etc just for the linking purpose.

    Regards,

  2. #2
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    517
    Thanks
    21
    Thanked 66 Times in 62 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qmake and library version handling

    since you are using versioning, file names are coming out to be different. now, either u add both -lmylib and -lmylib0 in -LIBS or u can avoid using the version tag..otherwise u'll hv to stick to platform-specific entries.

  3. #3
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qmake and library version handling

    Versioning *should* not be an issue. I have used it in several projects making use of shared libraries and it worked just fine without requiring any trick...

    AFAIK the following will always work, no matter the versioning :
    Qt Code:
    1. LIBS += -lmylib
    To copy to clipboard, switch view to plain text mode 

    Because the linker (is supposed to) take care of adding prefix/suffix/versioning to match the platform specific conventions when it searches for a matching shared lib.

    The only issue I can see in your pro is the space in the LIBS assignement. It ought to be written like that :
    Qt Code:
    1. LIBS += -L../mylib
    To copy to clipboard, switch view to plain text mode 
    Current Qt projects : QCodeEdit, RotiDeCode

  4. #4
    Join Date
    Feb 2008
    Posts
    26
    Thanks
    5
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: qmake and library version handling

    since you are using versioning, file names are coming out to be different. now, either u add both -lmylib and -lmylib0 in -LIBS or u can avoid using the version tag..otherwise u'll hv to stick to platform-specific entries.
    Specifying both -lmylib and -l mylib0 does not work (which is correct since the linker will try to open both libraries but only one exists!)

    Because the linker (is supposed to) take care of adding prefix/suffix/versioning to match the platform specific conventions when it searches for a matching shared lib.
    Apparently, this is not the case on windows. I've tried with QtCreator/MinGW and -lmylib does not work. I've tried to import my .pro file into VisualStudio using the QtVSIntegration, and it does not work too. I've even tried with nmake inside a console without success.

    PS: I wrote "LIBS += -L../mylib" in my .pro file, without spaces. I've introduced the error while writing the post

Similar Threads

  1. qmake: dependency of application on common shared library
    By PeterWurmsdobler in forum Qt Programming
    Replies: 5
    Last Post: 27th March 2009, 17:13
  2. qmake sux a lot
    By singermornings in forum Qt Programming
    Replies: 6
    Last Post: 29th January 2009, 09:33
  3. Adding library dependencies to qmake
    By sadastronaut in forum Installation and Deployment
    Replies: 2
    Last Post: 18th March 2008, 18:06
  4. Compiling with Qmake/Make
    By VireX in forum Newbie
    Replies: 25
    Last Post: 22nd February 2007, 06:57
  5. Win32 qmake: building a static library
    By Amanda in forum Qt Programming
    Replies: 5
    Last Post: 8th November 2006, 20:32

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.