Static build Qt application with dynamic link with 3rd party library.



  • Hi,

    If I build an application by static Qt compile, do I have to include 3rd party library statically not dynamically?
    And if I build an application by dynamic Qt compile, do I have to include 3rd party library dynamically not statically?



  • Nope, the link method of a library does nothing for the linking method of other libraries. You are free to mix and match as much as you want.

    The exception is cross dependency:

    • Library A links to Library B dynamically
    • Application C links to library B statically and to library A
    • Bad things happen


  • @VRonin

    Thank you. Do you mean that:
    App <--S--> libA <--S--> libB (O)
    App <--D--> libA <--D--> libB (O)
    App <--D--> libA <--S--> libB (O)
    App <--S--> libA <--D--> libB (X)



  • not quite, all your cases are ok

           ┌ ⇒ D ⇒ libA ⇒ D ⇒ libB
    Ok: App┤
           └ ⇒ D ⇒ libB
    
           ┌ ⇒ S ⇒ libA ⇒ D ⇒ libB
    Ok: App┤
           └ ⇒ D ⇒ libB
    
           ┌ ⇒ S ⇒ libA ⇒ S ⇒ libB
    Ok: App┤
           └ ⇒ S ⇒ libB
    
           ┌ ⇒ D ⇒ libA ⇒ D ⇒ libB
    No: App┤
           └ ⇒ S ⇒ libB
    


  • @VRonin
    How about following thee cases?

       ┌ ⇒ D ⇒ libA ⇒ S ⇒ libB
    App┤
       └ ⇒ S ⇒ libB
    
       ┌ ⇒ D ⇒ libA ⇒ S ⇒ libB
    App┤
       └ ⇒ D ⇒ libB
    
       ┌ ⇒ S ⇒ libA ⇒ S ⇒ libB
    App┤
       └ ⇒ D ⇒ libB


    1. I think it's ok
    2. No
    3. No


  • @VRonin

    Thank you for your detail explain. It sounds clearer now.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.