<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Can&#x27;t generate shared library on ubuntu and can&#x27;t link statically to a static library]]></title><description><![CDATA[<p dir="auto">Hi all,<br />
I started a new project in Qt creator and chose c++ library and from it dynamic library on ubuntu when I build the project I end up with .a file not .so can anybody explain to me what I am doing wrong ?</p>
<p dir="auto">second problem is that when I try to link the shared library against a static library through add library it appears as it will link statically as wanted and it build without any error but the deployed shared library is much smaller than the static library and when I test it using another program it throws an error of no definition of static library's class and functions.</p>
<p dir="auto">Any help would be greatly appreciated.<br />
Thanks in advance.</p>
]]></description><link>https://forum.qt.io/topic/97584/can-t-generate-shared-library-on-ubuntu-and-can-t-link-statically-to-a-static-library</link><generator>RSS for Node</generator><lastBuildDate>Sat, 18 Apr 2026 04:19:06 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/97584.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 13 Dec 2018 07:17:36 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Can&#x27;t generate shared library on ubuntu and can&#x27;t link statically to a static library on Tue, 18 Dec 2018 17:53:57 GMT]]></title><description><![CDATA[<p dir="auto">Ok, from you .pro file it looked like you were generating libraries.</p>
]]></description><link>https://forum.qt.io/post/500109</link><guid isPermaLink="true">https://forum.qt.io/post/500109</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Tue, 18 Dec 2018 17:53:57 GMT</pubDate></item><item><title><![CDATA[Reply to Can&#x27;t generate shared library on ubuntu and can&#x27;t link statically to a static library on Tue, 18 Dec 2018 13:53:21 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sgaist">@<bdi>SGaist</bdi></a></p>
<p dir="auto">Hi ,<br />
what I understood from cmake documentation is that add_library() configure the current project as a library and don't add an external library what I used instead was target_link_libraries() and it did the job indeed.</p>
]]></description><link>https://forum.qt.io/post/500052</link><guid isPermaLink="true">https://forum.qt.io/post/500052</guid><dc:creator><![CDATA[Mohammedbie]]></dc:creator><pubDate>Tue, 18 Dec 2018 13:53:21 GMT</pubDate></item><item><title><![CDATA[Reply to Can&#x27;t generate shared library on ubuntu and can&#x27;t link statically to a static library on Sun, 16 Dec 2018 21:09:15 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">You set that in the call to <a href="https://cmake.org/cmake/help/latest/command/add_library.html" target="_blank" rel="noopener noreferrer nofollow ugc">add_library</a>.</p>
]]></description><link>https://forum.qt.io/post/499552</link><guid isPermaLink="true">https://forum.qt.io/post/499552</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Sun, 16 Dec 2018 21:09:15 GMT</pubDate></item><item><title><![CDATA[Reply to Can&#x27;t generate shared library on ubuntu and can&#x27;t link statically to a static library on Sun, 16 Dec 2018 14:12:20 GMT]]></title><description><![CDATA[<p dir="auto">Ok thanks.</p>
]]></description><link>https://forum.qt.io/post/499488</link><guid isPermaLink="true">https://forum.qt.io/post/499488</guid><dc:creator><![CDATA[Mohammedbie]]></dc:creator><pubDate>Sun, 16 Dec 2018 14:12:20 GMT</pubDate></item><item><title><![CDATA[Reply to Can&#x27;t generate shared library on ubuntu and can&#x27;t link statically to a static library on Sun, 16 Dec 2018 14:08:12 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mohammedbie">@<bdi>Mohammedbie</bdi></a> said in <a href="/post/499471">Can't generate shared library on ubuntu and can't link statically to a static library</a>:</p>
<blockquote>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sierdzio">@<bdi>sierdzio</bdi></a>  sorry for bothering you but one last thing how to convert those lines to a cmake line ?</p>
<p dir="auto">Thanks in advance</p>
</blockquote>
<p dir="auto">No idea, I don't know cmake well enough.</p>
]]></description><link>https://forum.qt.io/post/499487</link><guid isPermaLink="true">https://forum.qt.io/post/499487</guid><dc:creator><![CDATA[sierdzio]]></dc:creator><pubDate>Sun, 16 Dec 2018 14:08:12 GMT</pubDate></item><item><title><![CDATA[Reply to Can&#x27;t generate shared library on ubuntu and can&#x27;t link statically to a static library on Sun, 16 Dec 2018 11:56:30 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sierdzio">@<bdi>sierdzio</bdi></a>  sorry for bothering you but one last thing how to convert those lines to a cmake line ?</p>
<p dir="auto">Thanks in advance</p>
]]></description><link>https://forum.qt.io/post/499471</link><guid isPermaLink="true">https://forum.qt.io/post/499471</guid><dc:creator><![CDATA[Mohammedbie]]></dc:creator><pubDate>Sun, 16 Dec 2018 11:56:30 GMT</pubDate></item><item><title><![CDATA[Reply to Can&#x27;t generate shared library on ubuntu and can&#x27;t link statically to a static library on Thu, 13 Dec 2018 13:43:05 GMT]]></title><description><![CDATA[<p dir="auto">Thank you very much .<br />
This solved it.</p>
]]></description><link>https://forum.qt.io/post/498953</link><guid isPermaLink="true">https://forum.qt.io/post/498953</guid><dc:creator><![CDATA[Mohammedbie]]></dc:creator><pubDate>Thu, 13 Dec 2018 13:43:05 GMT</pubDate></item><item><title><![CDATA[Reply to Can&#x27;t generate shared library on ubuntu and can&#x27;t link statically to a static library on Thu, 13 Dec 2018 13:03:07 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mohammedbie">@<bdi>Mohammedbie</bdi></a> said in <a href="/post/498931">Can't generate shared library on ubuntu and can't link statically to a static library</a>:</p>
<blockquote>
<p dir="auto">something I didn't mention as I didn't think it was related , I build the shared library with Qt static library which I built from sources .<br />
Now when I try to build the shared library with the same version of Qt but dynamic it builds and generates .so file and the test application runs normally.<br />
What might cause this ?</p>
</blockquote>
<p dir="auto">Hm, not sure but maybe your Qt config or mkspecs leak into definitions of your project when qmake is run.</p>
<p dir="auto">Try adding this in your shared lib .pro file:</p>
<pre><code>CONFIG -= staticlib
CONFIG += shared
</code></pre>
]]></description><link>https://forum.qt.io/post/498936</link><guid isPermaLink="true">https://forum.qt.io/post/498936</guid><dc:creator><![CDATA[sierdzio]]></dc:creator><pubDate>Thu, 13 Dec 2018 13:03:07 GMT</pubDate></item><item><title><![CDATA[Reply to Can&#x27;t generate shared library on ubuntu and can&#x27;t link statically to a static library on Thu, 13 Dec 2018 12:46:02 GMT]]></title><description><![CDATA[<p dir="auto">something I didn't mention as I didn't think it was related , I build the shared library with Qt static library which I built from sources .<br />
Now when I try to build the shared library with the same version of Qt but dynamic it builds and generates .so file and the test application runs normally.<br />
What might cause this ?</p>
]]></description><link>https://forum.qt.io/post/498931</link><guid isPermaLink="true">https://forum.qt.io/post/498931</guid><dc:creator><![CDATA[Mohammedbie]]></dc:creator><pubDate>Thu, 13 Dec 2018 12:46:02 GMT</pubDate></item><item><title><![CDATA[Reply to Can&#x27;t generate shared library on ubuntu and can&#x27;t link statically to a static library on Thu, 13 Dec 2018 08:12:02 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sierdzio">@<bdi>sierdzio</bdi></a></p>
<p dir="auto">Tried both with the same result too.</p>
]]></description><link>https://forum.qt.io/post/498881</link><guid isPermaLink="true">https://forum.qt.io/post/498881</guid><dc:creator><![CDATA[Mohammedbie]]></dc:creator><pubDate>Thu, 13 Dec 2018 08:12:02 GMT</pubDate></item><item><title><![CDATA[Reply to Can&#x27;t generate shared library on ubuntu and can&#x27;t link statically to a static library on Thu, 13 Dec 2018 08:08:23 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mohammedbie">@<bdi>Mohammedbie</bdi></a> said in <a href="/post/498879">Can't generate shared library on ubuntu and can't link statically to a static library</a>:</p>
<blockquote>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sierdzio">@<bdi>sierdzio</bdi></a></p>
<p dir="auto">tried adding the following line with the same result :</p>
<pre><code>LIBS += /home/softlock/build-StaticTest-Desktop_Qt_5_8_0_GCC_64bit-Debug/libStaticTest.a
</code></pre>
</blockquote>
<p dir="auto">Sorry I should have been more specific. You can provide full path to <code>-l</code> flag:</p>
<pre><code>LIBS += -l/home/softlock/build-StaticTest-Desktop_Qt_5_8_0_GCC_64bit-Debug/libStaticTest.a
</code></pre>
<p dir="auto">Or, another option is to use the file name specifier:</p>
<pre><code>unix:!macx: LIBS += -L$$PWD/../build-StaticTest-Desktop_Qt_5_8_0_GCC_64bit-Debug/ -l:libStaticTest.a
</code></pre>
<p dir="auto">Still, I don't know if that'll work.</p>
]]></description><link>https://forum.qt.io/post/498880</link><guid isPermaLink="true">https://forum.qt.io/post/498880</guid><dc:creator><![CDATA[sierdzio]]></dc:creator><pubDate>Thu, 13 Dec 2018 08:08:23 GMT</pubDate></item><item><title><![CDATA[Reply to Can&#x27;t generate shared library on ubuntu and can&#x27;t link statically to a static library on Thu, 13 Dec 2018 08:06:09 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sierdzio">@<bdi>sierdzio</bdi></a></p>
<p dir="auto">tried adding the following line with the same result :</p>
<pre><code>LIBS += /home/softlock/build-StaticTest-Desktop_Qt_5_8_0_GCC_64bit-Debug/libStaticTest.a
</code></pre>
]]></description><link>https://forum.qt.io/post/498879</link><guid isPermaLink="true">https://forum.qt.io/post/498879</guid><dc:creator><![CDATA[Mohammedbie]]></dc:creator><pubDate>Thu, 13 Dec 2018 08:06:09 GMT</pubDate></item><item><title><![CDATA[Reply to Can&#x27;t generate shared library on ubuntu and can&#x27;t link statically to a static library on Thu, 13 Dec 2018 07:57:04 GMT]]></title><description><![CDATA[<p dir="auto">Hm, code looks good to be honest.</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mohammedbie">@<bdi>Mohammedbie</bdi></a> said in <a href="/post/498873">Can't generate shared library on ubuntu and can't link statically to a static library</a>:</p>
<blockquote>
<p dir="auto">unix:!macx: LIBS += -L$$PWD/../build-StaticTest-Desktop_Qt_5_8_0_GCC_64bit-Debug/ -lStaticTest</p>
</blockquote>
<p dir="auto">Is there a .a in that folder? Perhaps you need to link specifically to .a and not use the general <code>-l</code> flag.</p>
]]></description><link>https://forum.qt.io/post/498876</link><guid isPermaLink="true">https://forum.qt.io/post/498876</guid><dc:creator><![CDATA[sierdzio]]></dc:creator><pubDate>Thu, 13 Dec 2018 07:57:04 GMT</pubDate></item><item><title><![CDATA[Reply to Can&#x27;t generate shared library on ubuntu and can&#x27;t link statically to a static library on Thu, 13 Dec 2018 07:39:58 GMT]]></title><description><![CDATA[<p dir="auto">Thanks for the fast reply , here are the .pro files :</p>
<p dir="auto"><strong>shared library .pro :</strong></p>
<pre><code>#-------------------------------------------------
#
# Project created by QtCreator 2018-12-11T23:18:12
#
#-------------------------------------------------

QT       -= gui

TARGET = DLLtest
TEMPLATE = lib

DEFINES += DLLTEST_LIBRARY

# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS

# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0

SOURCES += dlltest.cpp

HEADERS += dlltest.h\
        dlltest_global.h

unix {
    target.path = /usr/lib
    INSTALLS += target
}

unix:!macx: LIBS += -L$$PWD/../build-StaticTest-Desktop_Qt_5_8_0_GCC_64bit-Debug/ -lStaticTest

INCLUDEPATH += $$PWD/../StaticTest
DEPENDPATH += $$PWD/../StaticTest

unix:!macx: PRE_TARGETDEPS += $$PWD/../build-StaticTest-Desktop_Qt_5_8_0_GCC_64bit-Debug/libStaticTest.a

</code></pre>
<p dir="auto"><strong>Static library .pro :</strong></p>
<pre><code>#-------------------------------------------------
#
# Project created by QtCreator 2018-12-12T01:26:48
#
#-------------------------------------------------

QT       -= gui

TARGET = StaticTest
TEMPLATE = lib
CONFIG += staticlib

# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS

# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0

SOURCES += statictest.cpp

HEADERS += statictest.h
unix {
    target.path = /usr/lib
    INSTALLS += target
}

</code></pre>
<p dir="auto"><strong>Test program .pro :</strong></p>
<pre><code>QT += core
QT -= gui

CONFIG += c++11

TARGET = test
CONFIG += console
CONFIG -= app_bundle

TEMPLATE = app

SOURCES += main.cpp

# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS

# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0



unix:!macx: LIBS += -L$$PWD/./ -lDLLtest

INCLUDEPATH += $$PWD/../DLLtest
DEPENDPATH += $$PWD/../DLLtest


</code></pre>
]]></description><link>https://forum.qt.io/post/498873</link><guid isPermaLink="true">https://forum.qt.io/post/498873</guid><dc:creator><![CDATA[Mohammedbie]]></dc:creator><pubDate>Thu, 13 Dec 2018 07:39:58 GMT</pubDate></item><item><title><![CDATA[Reply to Can&#x27;t generate shared library on ubuntu and can&#x27;t link statically to a static library on Thu, 13 Dec 2018 07:25:43 GMT]]></title><description><![CDATA[<p dir="auto">Can you share the relevant parts of your .pro files for both issues you mention?</p>
]]></description><link>https://forum.qt.io/post/498870</link><guid isPermaLink="true">https://forum.qt.io/post/498870</guid><dc:creator><![CDATA[sierdzio]]></dc:creator><pubDate>Thu, 13 Dec 2018 07:25:43 GMT</pubDate></item></channel></rss>