Problems with Open-Source Downloads read and

load shared library in android with dlopen

  • I'm trying to load a shared library on android with dlopen.

    here is my code:

    QFile ddd("/data/data/org.qtproject.example.Mobiledinamicload/files/");
        void *libuntitled1 = dlopen("/data/user/0/org.qtproject.example.Mobiledinamicload/files/", RTLD_LAZY);
            if (!libuntitled1) {

    but not works and writes this errors on console:

    D true
    D szzzzzzzzzzz
    I qtMainLoopThrea: type=1400 audit(0.0:37736): avc: denied { open } for path="/data/data/org.qtproject.example.Mobiledinamicload/files/" dev="mmcblk0p19" ino=245815 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:object_r:app_data_file:s0 tclass=file permissive=1

    it works on android studio and i can use the library :

    extern "C" JNIEXPORT jstring JNICALL
            JNIEnv* env,
            jobject /* this */) {
        std::string hello_str ="Hello from C++ shared library";
        void *libuntitled1 = dlopen("/data/data/aaa.bbb.testnativecppqt/files/", RTLD_LAZY);
        if (!libuntitled1) {
            hello_str ="cant load shared library";
            return env->NewStringUTF(hello_str.c_str());
    // call functions from library
        return env->NewStringUTF(hello_str.c_str());

    load with QLibrary not works too:

            auto path = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
            QString fileName= path+"/";
            QFile ddd(fileName);
        QLibrary myLib(fileName);

    here is the error of QLibrary:

    D true
    D true
    I qtMainLoopThrea: type=1400 audit(0.0:38721): avc: denied { open } for path="/data/data/org.qtproject.example.Mobiledinamicload/files/" dev="mmcblk0p19" ino=245778 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:object_r:app_data_file:s0 tclass=file permissive=1
    D false
    D "Cannot load library /data/user/0/org.qtproject.example.Mobiledinamicload/files: (dlopen failed: library \"_data_user_0_org.qtproject.example.Mobiledinamicload_files\" not found)"

    --> my phone is rooted and i can copy any file to any path manually and change files permissions

  • Lifetime Qt Champion

    You are showing 3 different libraries:

  • @jsulm
    All these files are the same.
    I changed the name of the library during various tests and I wrote down the errors elsewhere.
    I forgot to correct them when writing this topic.
    Thanks for letting me know.
    I corrected them now.

Log in to reply