0

I want to build a static qt application. First of all I build qt static version on my linux machine. In the first time when I builded static application, I received errors because my qt can't link my application with some linux *.so librarys. I fixed it by using

unix{ QMAKE_LFLAGS += -static-libgcc -static-libstdc++ }

and my application now runs on every linux platform, intependetly from local linux libraris, it doesn't linking with local linux .so files. I want to do that think also with my protobuf files. I didn't found in internet how to do that. So I'm asking for help in here. I add pro file below.

QT       += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = EthernetAntCtrl_app
TEMPLATE = app
ROOT = ./..

DESTDIR = $$ROOT/bin
TMP_PRG_DIR = $$ROOT/tmp
MOC_DIR = $$TMP_PRG_DIR/$$TARGET/moc
OBJECTS_DIR = $$TMP_PRG_DIR/$$TARGET/obj
UI_DIR = $$TMP_PRG_DIR/$$TARGET/ui
RCC_DIR = $$TMP_PRG_DIR/$$TARGET/resources

PROTOBUF_DIR = /usr/local/include/google/protobuf
include($$ROOT/status_monitoring/status_monitoring.pri)
include($$ROOT/qt-propertybrowser/src/qtpropertybrowser.pri)

DEFINES += QT_DEPRECATED_WARNINGS
#-static-libprotobuf
unix{
     QMAKE_LFLAGS += -static-libgcc -static-libstdc++ 
}

SOURCES += \
    main.cpp \
    mainwindow.cpp \
interconnect.cpp \
switch.cpp \
../Common/MyLog.cpp \
../DevMan/DevmanLibraryController/CmdBase.cpp \
../DevMan/DevmanLibraryController/DevmanLibraryController.cpp \
../DevMan/Common/Names/CommonNames.cpp \
../DevMan/Common/Names/SystemMessageNames.cpp \
../DevMan/DevmanLibraryController/ConnectMsgs/TcpConnectMessage.cpp \
../DevMan/DevmanLibraryController/ConnectMsgs/TcpDisconnectMessage.cpp \
../DevMan/DevmanLibraryController/InitDeviceManagerMsgs/ResultMessage.cpp \
Msgs/InitDeviceManager_AntCtrl.cpp \
textedit.cpp \
pushbutton.cpp \
controller.cpp \
Msgs/CustomNames.cpp \
Msgs/AntCntrlMessage.cpp \
button_style.cpp \
ClientParameterManager.cpp \
../DevMan/DevmanLibraryController/ConnectMsgs/UdpConnectMessage.cpp \
../DevMan/DevmanLibraryController/ConnectMsgs/UdpDisconnectMessage.cpp \
LedButton.cpp

HEADERS += \
switch.h \
    mainwindow.h \
interconnect.h \
structureofpackets.h \
../Common/MacroDefines.h \
../Common/MyLog.h \
../DevMan/DevmanLibraryController/CmdBase.h \
../DevMan/DevmanLibraryController/DevmanLibraryController.h \
../DevMan/Common/Names/CommonNames.h \
../DevMan/Common/Names/SystemMessageNames.h \
../DevMan/DevmanLibraryController/ConnectMsgs/TcpConnectMessage.h \
../DevMan/DevmanLibraryController/ConnectMsgs/TcpDisconnectMessage.h \
../DevMan/DevmanLibraryController/InitDeviceManagerMsgs/ResultMessage.h \
Msgs/InitDeviceManager_AntCtrl.h \
textedit.h \
pushbutton.h \
controller.h \
Msgs/CustomNames.h \
Msgs/AntCntrlMessage.h \
button_style.h \
ClientParameterManager.h \
../DevMan/DevmanLibraryController/ConnectMsgs/UdpConnectMessage.h \
../DevMan/DevmanLibraryController/ConnectMsgs/UdpDisconnectMessage.h \
LedButton.h

FORMS += \
    mainwindow.ui


defineTest(copyToDestdir) {
files = $$1


#copyToDestdir($$PWD/ClientGuiConfig.ini)
scopchanov
  • 7,966
  • 10
  • 40
  • 68
Albert
  • 81
  • 2
  • 8
  • I don't know what this `protobuff` is, but I see in wikipedia there is some header files there, if so, I don't think you can put header files in your executable like static libraries. You should create a package (rpm, deb..) or just a simple compressed file .tar.gz with all your stuff there. – Phiber Sep 12 '18 at 14:44
  • No, I compiled google protobuf files and receive *.so protobuf libraries, After that I added them with the other *.so files in my linux.(in /usr/lib64 ) In other pro file I wrote LIBS += -lprotobuf, for linking to thi library, but i want to be linked statically. Without any dependecys from *.so files. – Albert Sep 12 '18 at 16:26

0 Answers0