Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Qt project with custom shared library cross compile Qt
drewpol last edited by
I built Qt 5.9.4 for cross-compile on Raspberry Pi 3. Everything works fine with test applications. My problem is following:
Created static library in Qt Creator which is named
SlaveDeviceModels. I deployed this library to raspberry and run this command on rpi:
Then I created console application project which is named
SmartHomeServerand added to this project external library
SlaveDeviceModels. Then I tried to run this application through Qt Creator but I get error:
/home/pi/Documents/QtProjectsTests/SmartHomeServer/SmartHomeServer: error while loading shared libraries: libSlaveDeviceModels.so.1: cannot open shared object file: No such file or directory Application finished with exit code 127.
So I go to rpi folder and it looks following:
pi@raspberrypi:~/Documents/QtProjectsTests/SmartHomeServer $ ls -l total 3048 -rwxr-xr-x 1 pi pi 2122400 Mar 17 14:10 SmartHomeServer -rw-r--r-- 1 pi pi 9006 Mar 17 14:04 SmartHomeServer.log lrwxrwxrwx 1 pi pi 29 Mar 17 13:28 libSlaveDeviceModels.so -> libSlaveDeviceModels.so.1.0.0 lrwxrwxrwx 1 pi pi 29 Mar 17 13:28 libSlaveDeviceModels.so.1 -> libSlaveDeviceModels.so.1.0.0 lrwxrwxrwx 1 pi pi 29 Mar 17 13:28 libSlaveDeviceModels.so.1.0 -> libSlaveDeviceModels.so.1.0.0 -rwxr-xr-x 1 pi pi 980428 Mar 17 13:28 libSlaveDeviceModels.so.1.0.0
Then I tried to run this app by
./SmartHomeServerand it worked fine. It started.
Only problem is when I'm trying to start
SmartHomeServerfrom Qt Creator on my local computer (cross-compile). Does anyone can help me where might be problem. Maybe missing settings in Qt Creator?
This is my
QT += core QT -= gui CONFIG += c++11 TARGET = SmartHomeServer 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 # Default rules for deployment. target.path = /home/pi/Documents/QtProjectsTests/SmartHomeServer INSTALLS += target # here are included my headers INCLUDEPATH += $$PWD/../SlaveDeviceModels # I tried do something like that #LIBS += -L/home/pi/Documents/QtProjectsTests/SmartHomeServe -lSlaveDeviceModels # that are default lines added by qt creator unix:!macx: LIBS += -L$$PWD/../build-SlaveDeviceModels-Raspberry_Pi_3_Kit-Debug/ -lSlaveDeviceModels INCLUDEPATH += $$PWD/../build-SlaveDeviceModels-Raspberry_Pi_3_Kit-Debug DEPENDPATH += $$PWD/../build-SlaveDeviceModels-Raspberry_Pi_3_Kit-Debug
koahnig last edited by
A static library is not a shared library. See here
A static library is staically linked to an application making the application bigger.
A shared library is a library which is shared between applications. Typically the sum of bytes required for all apps and libraries shall be less than the sum of bytes when you link the same applications with the same static library.
When you have source which is used in more than one applciation, you typically create a library which is linked to the different applications. However, this library may be static or dynamic/shared. When you are creating a dynamic/shared library you will receive a static and the actual dynamic/shared library. The static part is containing the so-called stubs which are basically defining the entries to the routines in the shared/dynamic library.