1

I want to compile a static library for Qt Project version 4.7.4. But whatever I'm changing in .pro file it will not affecting on changes. I want change for example libQt5Gui.so to point on /opt/vendor/extlib/libQt5Gui.so, but I'm not lucky at moment:

I'm copying files from Ubuntu to virtual machine on cleanly installed Xubuntu 13.04.

When I'm using ldd command it returns:

marin@host:~/some_dir/test$ ldd ./Project02
linux-gate.so.1 =>  (0xb76e7000)
libQt5Widgets.so.5 => /usr/lib/i386-linux-gnu/libQt5Widgets.so.5 (0xb70c6000)
libQt5Xml.so.5 => /usr/lib/i386-linux-gnu/libQt5Xml.so.5 (0xb708a000)
libQt5Gui.so.5 => not found
libQt5Core.so.5 => not found
libstdc++.so.6 => /usr/lib/i386-linux-gnu/libstdc++.so.6 (0xb6fa0000)
libgcc_s.so.1 => /lib/i386-linux-gnu/libgcc_s.so.1 (0xb6f83000)
libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xb6dd0000)
libQt5Gui.so.5 => not found
libQt5Core.so.5 => not found
libpthread.so.0 => /lib/i386-linux-gnu/libpthread.so.0 (0xb6db4000)
libgobject-2.0.so.0 => /usr/lib/i386-linux-gnu/libgobject-2.0.so.0 (0xb6d64000)
libglib-2.0.so.0 => /lib/i386-linux-gnu/libglib-2.0.so.0 (0xb6c63000)
libX11.so.6 => /usr/lib/i386-linux-gnu/libX11.so.6 (0xb6b2c000)
libm.so.6 => /lib/i386-linux-gnu/libm.so.6 (0xb6ae9000)
/lib/ld-linux.so.2 (0xb76e8000)
libQt5Core.so.5 => not found
libffi.so.6 => /usr/lib/i386-linux-gnu/libffi.so.6 (0xb6ae2000)
libpcre.so.3 => /lib/i386-linux-gnu/libpcre.so.3 (0xb6aa1000)
libxcb.so.1 => /usr/lib/i386-linux-gnu/libxcb.so.1 (0xb6a7e000)
libdl.so.2 => /lib/i386-linux-gnu/libdl.so.2 (0xb6a79000)
libXau.so.6 => /usr/lib/i386-linux-gnu/libXau.so.6 (0xb6a75000)
libXdmcp.so.6 => /usr/lib/i386-linux-gnu/libXdmcp.so.6 (0xb6a6e000)

So you, i didn't figure why is:

libQt5Gui.so.5 => not found
libQt5Core.so.5 => not found

My .pro file:

QT       += core gui xml

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = Project02
TEMPLATE = app


SOURCES += main.cpp\
        mainwindow.cpp \
    editorplain.cpp \
    logssession.cpp \
    createcontroller.cpp \
    createmodel.cpp \
    createview.cpp \
    envview.cpp \
    properties.cpp \
    debugsettings.cpp \
    serverconf.cpp \
    frameworkview.cpp \
    helpergen.cpp \
    offlineserver.cpp \
    cssproperty.cpp \
    regex.cpp \
    formgen.cpp

HEADERS  += mainwindow.h \
    editorplain.h \
    logssession.h \
    createcontroller.h \
    createmodel.h \
    createview.h \
    envview.h \
    properties.h \
    debugsettings.h \
    serverconf.h \
    frameworkview.h \
    helpergen.h \
    offlineserver.h \
    cssproperty.h \
    regex.h \
    formgen.h

FORMS    += mainwindow.ui \
    editorplain.ui \
    logssession.ui \
    createcontroller.ui \
    createmodel.ui \
    createview.ui \
    envview.ui \
    properties.ui \
    debugsettings.ui \
    serverconf.ui \
    frameworkview.ui \
    helpergen.ui \
    offlineserver.ui \
    cssproperty.ui \
    regex.ui \
    formgen.ui

RESOURCES += \
    res.qrc

CONFIG += staticlib

LIBS += -L$$PWD/extstaticlibs/ -lFoobar
INCLUDEPATH += $$PWD/extstaticlibs

In .pro file i've added only:

CONFIG += staticlib

LIBS += -L$$PWD/extstaticlibs/ -lFoobar
INCLUDEPATH += $$PWD/extstaticlibs

On $$PWD/extstaticlibs there is copy files of libQt5Gui.so.5.

So, have to make static library works without dynamic shared .so Qt scripts as standalone app? Thank you!

2
  • To link against static Qt libraries you need to build a static version of Qt (run ./configure --help in Qt source directory to see how to do it). And why are you referring at 4.7.4 version, while you are obviously using Qt5? Commented May 5, 2013 at 14:56
  • I'm working on Qt5, but some widgets are worked in version 4 so .pro file is there. Please give me some really example that really works. I've found a YT link for static comple so using g++ --static Commented May 5, 2013 at 18:03

1 Answer 1

1

I solved this question. Using g++ --static --release and compile with minigw under Windows machine would solved this problem. A recommended version is use shared library of Qt due to better support for Qt libraries.

I solved this problem in Unix too, using DEB package and addding a shared library libqt5gui and libqt5core.

For static library i'm not solved fully yet, so I will not recommend using this solution due to incompatible gcc version and c++ compiler on other platforms. It will prevents for screwing up of compile codes.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.