Statically linking the openssl libraries?



  • In order to statically link the openssl libraries to my QT application do i have to RECOMPILe the whole qt library each time i want to statically link openssl into my application?

    for example i want to keep from having the following 2 seperate QT compiled libraries on my system

    C:\Qt\4.8.0[run time openssl linking]\

    C:\Qt\4.8.0[static openssl linking]\


  • Moderators

    No. You may create a static lib version of Qt and of openssl. As you do this with your dynamic version you have to compile only your application and link it against the desired version static or dynamically.



  • maybe i stated this a little wrong.

    Say i wanted my QT application to statically link to SSL. When setting up QT do i use the following

    configure -openssl-linked .......

    now everytime when i compile a QT application will it automatically statically link this library into my qt application when im not needing it?! if so how do i get around this :(?


  • Moderators

    I have not worked with openssl yet. Therefore, I am not sure how you have to link your applications. However, I assume that it is a separate library similar to the other different Qt libs (e.g. Network, Gui and so on). So I do not see a reason that all is lumped together all the time. That makes no sense.
    I think, I have to admit I am not complete sure, but the linker should take nowadays only the objects out of a required lib which are really referenced. Also this would not prevent that openssl objects are part of the executable when not required.
    20 years ago linkers just bound the whole lib into your executable, which was not optimal with a 640k RAM limit.
    If you really want to be sure, you could separate the openssl lib from the others. However, I would not recommend this in general, because makes things complicated.
    However, for a test you could do. Link a static application when the openssl lib is also in the directory with the other libs. Note the size of your exe and do the same when the lib is not pressent. This might convince you.



  • [quote author="maybnxtseasn" date="1332430324"]maybe i stated this a little wrong.

    Say i wanted my QT application to statically link to SSL. When setting up QT do i use the following

    configure -openssl-linked .......

    now everytime when i compile a QT application will it automatically statically link this library into my qt application when im not needing it?! if so how do i get around this :(? [/quote]

    Using -openssl-linked does not make openssl statically linked. What it does is switch from using dlopen() and dlsym() to load and call the openssl library and instead uses the normal dynamic linker. Using this option means that issues such as binary compatibility of the openssl library need to be handled or avoided, whereas the default of using dlopen() allows Qt to work around binary compatibility issues in openssl.

    It is possible that you could combine static linking with -openssl-linked though that's not a configuration that is tested by CI etc. If you did so then it would mean that your QtNetwork library would have a statically linked copy of openssl. Doing this is a very bad idea however, since it would make upgrading openssl much harder should any security issues in the library be found.



  • Ive compiled QT and run the following in command prompt

    configure -platform win32-msvc2010 -openssl-linked
    nmake

    QT compiles fines but when i go into my project and add a web browser to a simple QWindow and compile, it seems as if QT has not embedded openssl within the binary statically. Is there a step im missing?


  • Moderators

    You've already asked this question "here.":/forums/viewthread/15677/ and received quite a bit of feedback. Please don't double post.



  • Have you tride :
    @
    CONFIG += static
    @
    in your pro file



  • Have you tried :
    @
    CONFIG += static
    @
    in your pro file



  • I have merged two very similar topics by the same topic starter. Please don't duplicate your posts.



  • sorry It was my fault



  • [quote author="mlong" date="1332872630"]You've already asked this question "here.":/forums/viewthread/15677/ and received quite a bit of feedback. Please don't double post.
    [/quote]

    this link goes to this same page


Log in to reply
 

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