Adding library dependencies to Android Shared Library project
-
Thanks for the help, jsulm. That solved the issue!
-
Hello guys, i've tried link some third-party shared libraries into my android application, but always i've encountered this three errors :
:-1: warning: skipping incompatible /home/bruno/Documentos/Workspaces/Qt_Projects/brisa-project/platforms/qt/build-brisa/libbrisa.so while searching for brisa :-1: error: collect2: error: ld returned 1 exit status :-1: error: error: cannot find -lbrisa
i've already read a lot about this errors and i couldnt at least build the project.
i am using:
Qt 5.7 RC and QtCreator 4.0.1TEMPLATE = app QT += qml quick widgets network xml qtHaveModule(webengine) { QT += webengine DEFINES += QT_WEBVIEW_WEBENGINE_BACKEND } RESOURCES += View/qml.qrc \ Assets/pics/pics.qrc include(brisa.pri) DISTFILES += Assets/TO_DO.txt \ android/AndroidManifest.xml \ android/gradle/wrapper/gradle-wrapper.jar \ android/gradlew \ android/res/values/libs.xml \ android/build.gradle \ android/gradle/wrapper/gradle-wrapper.properties \ android/gradlew.bat HEADERS += \ Controller/controlpointbcu.h \ Controller/dataobject.h \ Controller/filedownloader.h \ Controller/folderCompressor.h \ Controller/essencials/qqmlhelpers.h \ Controller/essencials/qqmlobjectlistmodel.h SOURCES += Controller/main.cpp \ Controller/controlpointbcu.cpp \ Controller/dataobject.cpp \ Controller/filedownloader.cpp \ Controller/folderCompressor.cpp \ Controller/essencials/qqmlhelpers.cpp \ Controller/essencials/qqmlobjectlistmodel.cpp contains(ANDROID_TARGET_ARCH,armeabi-v7a) { ANDROID_EXTRA_LIBS = \ $$PWD/../../build-brisa/libbrisa.so } ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android
brisa.pri
BASEDIR_BRUNO = /home/bruno/Documentos/Workspaces/Qt_Projects/brisa-project/platforms/qt BASEDIR_MAC = /Users/compemac2/brisa-project/platforms/qt/build-brisa-iphonesimulator_clang_Qt_5_5_1_for_iOS-Debug/ INCLUDEPATH += $$BASEDIR_BRUNO/lib/include LIBS += -L$$BASEDIR_BRUNO/build-brisa -lbrisa
Compile Output
23:10:40: Running steps for project BCU... 23:10:40: Configuration unchanged, skipping qmake step. 23:10:40: Starting: "/usr/bin/make" /home/bruno/Documentos/Qt/5.7/android_armv7/bin/qmake -spec android-g++ -o Makefile ../BCU/BCU.pro /home/bruno/Documentos/Android/android-ndk-r11c/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-g++ --sysroot=/home/bruno/Documentos/Android/android-ndk-r11c/platforms/android-9/arch-arm/ -Wl,-soname,libBCU.so -Wl,-rpath=/home/bruno/Documentos/Qt/5.7/android_armv7/lib -Wl,--no-undefined -Wl,-z,noexecstack -shared -o libBCU.so main.o controlpointbcu.o dataobject.o filedownloader.o folderCompressor.o qqmlhelpers.o qqmlobjectlistmodel.o qrc_qml.o qrc_pics.o moc_controlpointbcu.o moc_dataobject.o moc_filedownloader.o moc_folderCompressor.o moc_qqmlhelpers.o moc_qqmlobjectlistmodel.o -L/home/bruno/Documentos/Android/android-ndk-r11c/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a -L/home/bruno/Documentos/Android/android-ndk-r11c/platforms/android-9/arch-arm//usr/lib -L/home/bruno/Documentos/Workspaces/Qt_Projects/brisa-project/platforms/qt/build-brisa -lbrisa -L/home/bruno/Documentos/Qt/5.7/android_armv7/lib -lQt5Quick -L/opt/android/ndk/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a -L/opt/android/ndk/platforms/android-9/arch-arm//usr/lib -lQt5Widgets -lQt5Gui -lQt5Qml -lQt5Network -lQt5Xml -lQt5Core -lGLESv2 -lgnustl_shared -llog -lz -lm -ldl -lc -lgcc /home/bruno/Documentos/Android/android-ndk-r11c/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9/../../../../arm-linux-androideabi/bin/ld: warning: skipping incompatible /home/bruno/Documentos/Workspaces/Qt_Projects/brisa-project/platforms/qt/build-brisa/libbrisa.so while searching for brisa Makefile:251: recipe for target 'libBCU.so' failed /home/bruno/Documentos/Android/android-ndk-r11c/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9/../../../../arm-linux-androideabi/bin/ld: error: cannot find -lbrisa main.o:main.cpp:function main: error: undefined reference to 'brisa::upnp::controlpoint::ControlPoint::start()' main.o:main.cpp:function main: error: undefined reference to 'brisa::upnp::controlpoint::ControlPoint::discover()' controlpointbcu.o:controlpointbcu.cpp:function ControlPointBCU::deviceRemoved(QString): error: undefined reference to 'brisa::upnp::controlpoint::ControlPoint::deviceGone(QString)' controlpointbcu.o:controlpointbcu.cpp:function ControlPointBCU::ControlPointBCU(QQmlApplicationEngine*, QObject*, QString, int): error: undefined reference to 'brisa::upnp::controlpoint::ControlPoint::ControlPoint(QObject*, QString, int)' controlpointbcu.o:controlpointbcu.cpp:function ControlPointBCU::ControlPointBCU(QQmlApplicationEngine*, QObject*, QString, int): error: undefined reference to 'brisa::upnp::controlpoint::ControlPoint::~ControlPoint()' controlpointbcu.o:controlpointbcu.cpp:function ControlPointBCU::replyFinished(QNetworkReply*): error: undefined reference to 'brisa::upnp::controlpoint::Device::Device(QTemporaryFile*, QUrl*, QObject*)' controlpointbcu.o:controlpointbcu.cpp:function ControlPointBCU::replyFinished(QNetworkReply*): error: undefined reference to 'brisa::upnp::controlpoint::Device::getAttribute(brisa::upnp::controlpoint::Device::xmlTags)' controlpointbcu.o:controlpointbcu.cpp:function ControlPointBCU::replyFinished(QNetworkReply*): error: undefined reference to 'brisa::upnp::controlpoint::Device::getAttribute(brisa::upnp::controlpoint::Device::xmlTags)' controlpointbcu.o:controlpointbcu.cpp:function ControlPointBCU::replyFinished(QNetworkReply*): error: undefined reference to 'brisa::upnp::controlpoint::Device::getServiceList()' controlpointbcu.o:controlpointbcu.cpp:function ControlPointBCU::replyFinished(QNetworkReply*): error: undefined reference to 'brisa::upnp::AbstractService::getAction(QString const&)' controlpointbcu.o:controlpointbcu.cpp:function ControlPointBCU::replyFinished(QNetworkReply*): error: undefined reference to 'brisa::upnp::controlpoint::Service::call(QString const&, QMap<QString, QString>&)' controlpointbcu.o:controlpointbcu.cpp:function ControlPointBCU::replyFinished(QNetworkReply*): error: undefined reference to 'brisa::upnp::AbstractService::setAttribute(brisa::upnp::AbstractService::xmlTags, QString const&)' controlpointbcu.o:controlpointbcu.cpp:function ControlPointBCU::replyFinished(QNetworkReply*): error: undefined reference to 'brisa::upnp::AbstractService::setAttribute(brisa::upnp::AbstractService::xmlTags, QString const&)' controlpointbcu.o:controlpointbcu.cpp:function ControlPointBCU::decodeJsonList(): error: undefined reference to 'brisa::upnp::controlpoint::Device::getAttribute(brisa::upnp::controlpoint::Device::xmlTags)' moc_controlpointbcu.o:moc_controlpointbcu.cpp:function ControlPointBCU::~ControlPointBCU(): error: undefined reference to 'brisa::upnp::controlpoint::ControlPoint::~ControlPoint()' moc_controlpointbcu.o:moc_controlpointbcu.cpp:function QMetaTypeIdQObject<brisa::upnp::controlpoint::Device*, 8>::qt_metatype_id(): error: undefined reference to 'brisa::upnp::controlpoint::Device::staticMetaObject' moc_controlpointbcu.o:moc_controlpointbcu.cpp:function ControlPointBCU::qt_metacast(char const*): error: undefined reference to 'brisa::upnp::controlpoint::ControlPoint::qt_metacast(char const*)' moc_controlpointbcu.o:moc_controlpointbcu.cpp:function ControlPointBCU::qt_metacall(QMetaObject::Call, int, void**): error: undefined reference to 'brisa::upnp::controlpoint::ControlPoint::qt_metacall(QMetaObject::Call, int, void**)' moc_controlpointbcu.o:moc_controlpointbcu.cpp:typeinfo for ControlPointBCU: error: undefined reference to 'typeinfo for brisa::upnp::controlpoint::ControlPoint' moc_controlpointbcu.o:moc_controlpointbcu.cpp:ControlPointBCU::staticMetaObject: error: undefined reference to 'brisa::upnp::controlpoint::ControlPoint::staticMetaObject' collect2: error: ld returned 1 exit status make: *** [libBCU.so] Error 1 23:10:40: The process "/usr/bin/make" exited with code 2. Error while building/deploying project BCU (kit: Android for armeabi-v7a (GCC 4.9, Qt 5.7.0)) When executing step "Make" 23:10:40: Elapsed time: 00:00.
Please, anyone can help me?
Sorry about the english =B -
@BrunoGeorgevich For which architecture is that library built? Is it for ARMv7? Which compiler was used to build it?
You can check this with:file /home/bruno/Documentos/Workspaces/Qt_Projects/brisa-project/platforms/qt/build-brisa/libbrisa.so
-
@jsulm the architecture is arm v7 and the compiler is GCC 5.2. That library really exists, but I didn't understand what you wanna say with "you can check this with". Again, I'm sorry about the English.
This shared library works when I built the project for desktop, using the GCC compiler, but with Android occurres this errors mentioned above.
-
@BrunoGeorgevich I mean: can you please execute this line on the command line and post its output here?
file /home/bruno/Documentos/Workspaces/Qt_Projects/brisa-project/platforms/qt/build-brisa/libbrisa.so
You cannot use the same library binary on desktop and Android/ARM! (unless your desktop is ARM as well)
-
@BrunoGeorgevich You have to build this library for ARMv7 or get a build for ARMv7 from somewhere. You cannot turn a x86 binary into ARMv7 binary.
-
@jsulm Do you know what i need do add to my qmake to compile this lib to ARM v7?
QT += core network xml gui CONFIG += console CONFIG += qt warn_on CONFIG += hardening CONFIG -= app_bundle TEMPLATE = lib TARGET = brisa INCLUDEPATH += "include" INCLUDEPATH += "src" #!exists( brisa.pri ) { ! brisa.pri { message("Creating the brisa.pri configuration file. Do not edit this file.") system(python scripts/gen_brisa_pri.py) QMAKE_CLEAN += brisa.pri } HEADERS += \ //all .h SOURCES += \ //all .cpp
I never do something like this, to compile a lib to ARM v7. The code above is the .pro of the lib. What i need to add to this code, to compile it to ARM v7?
-
@Igor-Oliveira what about this document: Compiling QT-Brisa to Android and generate the Apk File?
I didn't try the whole process, but as a result of the build steps, I'd expect the libbrisa.so for Android built somewhere in your workspace... -
@BrunoGeorgevich You don't have to change anything there. You have to use qmake and make from your ARMv7 build environment.