Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Lnk error ndk native android



  • I have problems with link ndk native to qt creator. Android for x86 Clang qt 5.12.8.

    My .pro file
       NDKLIB = -L"С:\ndk\21.2.6472646\21.2.6472646\toolchains\llvm\prebuilt\windows-x86_64\sysroot\usr\lib\i686-linux-android\29"
            LIBS += $$NDKLIB\libc.a
            LIBS += $$NDKLIB\libcompiler_rt-extras.a
            LIBS += $$NDKLIB\libdl.a
            LIBS += $$NDKLIB\libm.a
            LIBS += $$NDKLIB\libstdc++.a
            LIBS += $$NDKLIB\libz.a
            LIBS += $$NDKLIB\libmediandk.so
            LIBS += $$NDKLIB\libnativewindow.so
            LIBS += $$NDKLIB\libdl.so
            LIBS += $$NDKLIB\libandroid.so
            LIBS += $$NDKLIB\libGLESv2.so
            LIBS += $$NDKLIB\libstdc++.so
            LIBS += $$NDKLIB\libbinder_ndk.so
            LIBS += $$NDKLIB\libGLESv3.so
            LIBS += $$NDKLIB\libsync.so
            LIBS += $$NDKLIB\libjnigraphics.so
            LIBS += $$NDKLIB\libvulkan.so
            LIBS += $$NDKLIB\libc.so
            LIBS += $$NDKLIB\libz.so
    

    Compile Output

    error: undefined reference to 'ACameraManager_delete'
    error: undefined reference to 'ACameraManager_getCameraIdList'
    error: undefined reference to 'ACameraManager_getCameraCharacteristics'
    error: undefined reference to 'ACameraMetadata_getConstEntry'
    error: undefined reference to 'ACameraManager_deleteCameraIdList'
    error: undefined reference to 'AImageReader_setImageListener'
    error: undefined reference to 'AImageReader_new'
    error: undefined reference to 'AImageReader_setImageListener'
    error: undefined reference to 'AImageReader_getWindow'
    error: undefined reference to 'ACaptureSessionOutput_create'
    

  • Qt Champions 2019

    @JobRecrd I don't think you need -L for static linking:

    LIBS += "С:/ndk/21.2.6472646/21.2.6472646/toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/lib/i686-linux-android/29"
            LIBS += $$NDKLIB\libc.a
            LIBS += $$NDKLIB\libcompiler_rt-extras.a
            LIBS += $$NDKLIB\libdl.a
            LIBS += $$NDKLIB\libm.a
            LIBS += $$NDKLIB\libstdc++.a
            LIBS += $$NDKLIB\libz.a
            LIBS += -L$$NDKLIB -lmediandk
            LIBS += -L$$NDKLIB -lnativewindow
            LIBS += -L$$NDKLIB -ldl
            LIBS += -L$$NDKLIB -landroid
            LIBS += -L$$NDKLIB -lGLESv2
            LIBS += -L$$NDKLIB -lstdc++
            LIBS += -L$$NDKLIB -lbinder_ndk
            LIBS += -L$$NDKLIB -lGLESv3
            LIBS += -L$$NDKLIB -lsync
            LIBS += -L$$NDKLIB -ljnigraphics
            LIBS += -L$$NDKLIB -lvulkan
            LIBS += -L$$NDKLIB -lc
            LIBS += -L$$NDKLIB -lz
    

    Also you should use / instead of \ in pro files even on Windows.
    I'm wondering why you actually need to do this? Why do you link explicitly libc.so for example? And you're linking static and shared versions of libc!
    Can you explain what you are trying to do?


  • Qt Champions 2019

    @JobRecrd I don't think you need -L for static linking:

    LIBS += "С:/ndk/21.2.6472646/21.2.6472646/toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/lib/i686-linux-android/29"
            LIBS += $$NDKLIB\libc.a
            LIBS += $$NDKLIB\libcompiler_rt-extras.a
            LIBS += $$NDKLIB\libdl.a
            LIBS += $$NDKLIB\libm.a
            LIBS += $$NDKLIB\libstdc++.a
            LIBS += $$NDKLIB\libz.a
            LIBS += -L$$NDKLIB -lmediandk
            LIBS += -L$$NDKLIB -lnativewindow
            LIBS += -L$$NDKLIB -ldl
            LIBS += -L$$NDKLIB -landroid
            LIBS += -L$$NDKLIB -lGLESv2
            LIBS += -L$$NDKLIB -lstdc++
            LIBS += -L$$NDKLIB -lbinder_ndk
            LIBS += -L$$NDKLIB -lGLESv3
            LIBS += -L$$NDKLIB -lsync
            LIBS += -L$$NDKLIB -ljnigraphics
            LIBS += -L$$NDKLIB -lvulkan
            LIBS += -L$$NDKLIB -lc
            LIBS += -L$$NDKLIB -lz
    

    Also you should use / instead of \ in pro files even on Windows.
    I'm wondering why you actually need to do this? Why do you link explicitly libc.so for example? And you're linking static and shared versions of libc!
    Can you explain what you are trying to do?



  • @jsulm
    I needed to access the camera on the android platform. Your answer helped solve my problem, thanks.


Log in to reply