GLIBCXX_3.4.26' not found error?

Completed

Comments

11 comments

  • Avatar
    Andrey Terentyev

    Hello Mohamed,

    Most probably you are using Ubuntu 20.04 or similar, which has libstdc++  library version (3.4.26) different from the one the Server is using.

    For detail, see the metadata_sdk/src/nx/sdk/dynamic_libraries.md file.

    To resolve the issue, link the plugin statically.

    Here is the code for the CMakeLists.txt

    set(CMAKE_EXE_LINKER_FLAGS " -static")
    target_link_libraries(opencv_object_detection_analytics_plugin
    nx_kit
    nx_sdk
    opencv::opencv
    -static-libgcc
    -static-libstdc++)

    JIRA-VMS-23218

    0
    Comment actions Permalink
  • Avatar
    Mohamed Thasin

    Hello Andrey, 

    As you have mentioned, I am using Ubuntu 20.04. I am getting below error after adding your suggested changes in CMakeLists.txt file. 

     

    Release.

    -- Configuring done

    CMake Error at CMakeLists.txt:75 (add_library):

     Target "opencv_object_detection_analytics_plugin" links to target

    "opencv::opencv" but the target was not found. Perhaps a find_package()

    call is missing for an IMPORTED target, or an ALIAS target is missing?

    -- Generating done

    CMake Generate step failed. Build files cannot be regenerated correctly.

    CMake process exited with exit code 1.

     

    ...
    # Define opencv_object_detection_analytics_plugin lib, dynamic, depends on nx_kit and nx_sdk.
    set(OPENCV_OBJECT_DETECTION_ANALYTICS_PLUGIN_SRC_DIR ${CMAKE_CURRENT_LIST_DIR}/src)
    file(GLOB_RECURSE OPENCV_OBJECT_DETECTION_ANALYTICS_PLUGIN_SRC CONFIGURE_DEPENDS
    ${OPENCV_OBJECT_DETECTION_ANALYTICS_PLUGIN_SRC_DIR}/*)
    add_library(opencv_object_detection_analytics_plugin SHARED ${OPENCV_OBJECT_DETECTION_ANALYTICS_PLUGIN_SRC})
    target_include_directories(opencv_object_detection_analytics_plugin PRIVATE ${OPENCV_OBJECT_DETECTION_ANALYTICS_PLUGIN_SRC_DIR})
    set(CMAKE_EXE_LINKER_FLAGS " -static")
    target_link_libraries(opencv_object_detection_analytics_plugin PRIVATE nx_kit nx_sdk opencv::opencv
    -static-libgcc
    -static-libstdc++)
    target_compile_definitions(opencv_object_detection_analytics_plugin
    PRIVATE NX_PLUGIN_API=${API_EXPORT_MACRO}
    )
    0
    Comment actions Permalink
  • Avatar
    Andrey Terentyev

    Mohamed,

    Sorry. My bad. I took the code from the updated version, which is going to be merged into the repo soon.

    Here is the code that should work in your case

    set(CMAKE_EXE_LINKER_FLAGS " -static")
    target_link_libraries(opencv_object_detection_analytics_plugin
      nx_kit
      nx_sdk
      ${CONAN_LIBS}
      stdc++fs
      -static-libgcc
      -static-libstdc++)
    0
    Comment actions Permalink
  • Avatar
    Mohamed Thasin

    Andrey,

    After adding the suggested solution, I am getting . But still i am unable to load the plugin ange getting undefined symbol error. Here is the error message.

     

    {
    "description": "",
    "errorCode": "cannotLoadLibrary",
    "homeDir": "",
    "instanceIndex": -1,
    "isActive": true,
    "libName": "opencv_object_detection_analytics_plugin",
    "libraryFilename": "/opt/networkoptix-metavms/mediaserver/bin/plugins/libopencv_object_detection_analytics_plugin.so",
    "mainInterface": "undefined",
    "name": "",
    "nxSdkVersion": "",
    "optionality": "nonOptional",
    "resourceBindingInfo": [],
    "status": "notLoadedBecauseOfError",
    "statusMessage": "Failed loading Server Plugin [/opt/networkoptix-metavms/mediaserver/bin/plugins/libopencv_object_detection_analytics_plugin.so] (): [cannotLoadLibrary]: Cannot load library /opt/networkoptix-metavms/mediaserver/bin/plugins/libopencv_object_detection_analytics_plugin.so: (/opt/networkoptix-metavms/mediaserver/bin/plugins/libopencv_object_detection_analytics_plugin.so: undefined symbol: _ZTIN2cv9ExceptionE)",
    "vendor": "",
    "version": ""
    }

    Note: I couldn't add CONAN_LIBS due to issues from Conan. 

    0
    Comment actions Permalink
  • Avatar
    Mohamed Thasin

    I forgot to add ${OpenCV_LIBS}. After adding this still getting the same error GLIBCXX_3.4.26 not found. 

    This is how my target link librariries look like,

    target_link_libraries(opencv_object_detection_analytics_plugin PRIVATE nx_kit nx_sdk ${OpenCV_LIBS} stdc++fs -static-libgcc -static-libstdc++ )
     
    0
    Comment actions Permalink
  • Avatar
    Andrey Terentyev

    Mohamed,

    The path /opt/networkoptix-metavms/mediaserver/bin/plugins/ is not correct for the Step3.

    Please, read the "Organizing third party library files" section carefully. You should create a directory opencv_object_detection_analytics_plugin.

    The string

    undefined symbol: _ZTIN2cv9ExceptionE

    probably is symbol for the cv::Exception, which points to code inside the OpenCV library. That makes me think OpenCV either was not linked or can't be found.

    I read again through the CMakeLists.txt you've posted. You are using OpenCV from the custom location. I guess, this would work for you

    set(CMAKE_EXE_LINKER_FLAGS " -static")
    target_link_libraries(opencv_object_detection_analytics_plugin PRIVATE nx_kit nx_sdk
    ${OpenCV_LIBS}
    stdc++fs
    -static-libgcc
    -static-libstdc++)

     

     

     

     

    0
    Comment actions Permalink
  • Avatar
    Andrey Terentyev

    Mohamed,

    I had not seen your post, while I was writing mine. :)

    /opt/networkoptix-metavms/mediaserver/lib/libstdc++.so.6: version `GLIBCXX_3.4.26' not found (required by /usr/local/lib/libopencv_dnn.so.4.5)

    It seems, you are using a prebuilt version of OpenCV 4.5 provided via Ubuntu 20.04 package repositories, which was built depending on the GLIBCXX_3.4.26 and thus requires this version, while the Server uses another version of GLIBCXX.

     

     

    0
    Comment actions Permalink
  • Avatar
    Andrey Terentyev

    Try this CMakeLists.txt. It will build version OpenCV 4.1.2 and will statically link it to the plugin binary.
    Once again, read the "Organizing third party library files" section carefully.

    ## Copyright 2018-present Network Optix, Inc. Licensed under MPL 2.0: www.mozilla.org/MPL/2.0/

    cmake_minimum_required(VERSION 3.15)
    set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded")
    project(opencv_object_detection_analytics_plugin)

    set(metadataSdkVersion "4.2.0.32836 R4")
    set(metadataSdkDir "" CACHE PATH
    "Path to unpacked VMS Metadata SDK zip. Tested with version ${metadataSdkVersion}.")

    if(metadataSdkDir STREQUAL "")
    message(FATAL_ERROR "metadataSdkDir cache variable is undefined.")
    endif()

    list(APPEND CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR})
    list(APPEND CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR})

    # Download OpenCV automatically using Conan
    if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake")
    message(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan")
    file(DOWNLOAD "https://raw.githubusercontent.com/conan-io/cmake-conan/master/conan.cmake"
    "${CMAKE_BINARY_DIR}/conan.cmake")
    endif()
    include(${CMAKE_BINARY_DIR}/conan.cmake)

    if(WIN32)
    set(CONAN_VS_RUNTIME_MT_SETTING "compiler.runtime=MT")
    endif()
    set(OPENCV_OPTIONS
    opencv:parallel=False
    opencv:contrib=False
    opencv:contrib_freetype=False
    opencv:contrib_sfm=False
    opencv:with_jpeg=False
    opencv:with_png=False
    opencv:with_tiff=False
    opencv:with_jpeg2000=False
    opencv:with_openexr=False
    opencv:with_eigen=False
    opencv:with_webp=False
    opencv:with_quirc=False
    opencv:with_cuda=False
    opencv:with_cublas=False
    opencv:dnn=True)

    if(UNIX)
    set(OPENCV_OPTIONS
    ${OPENCV_OPTIONS}
    opencv:fPIC=True
    opencv:with_gtk=False
    opencv:with_cufft=False
    opencv:with_v4l=False)
    endif()

    conan_cmake_run(BUILD_TYPE "Release")
    conan_cmake_configure(REQUIRES opencv/4.1.2
    GENERATORS cmake_find_package
    OPTIONS ${OPENCV_OPTIONS}
    SETTINGS ${CONAN_VS_RUNTIME_MT_SETTING})

    conan_cmake_install(PATH_OR_REFERENCE .
    OPTIONS ${OPENCV_OPTIONS}
    SETTINGS ${CONAN_VS_RUNTIME_MT_SETTING}
    BUILD missing)

    find_package(OpenCV REQUIRED)

    # Download model files
    set(model_file_names
    MobileNetSSD.caffemodel
    MobileNetSSD.prototxt
    )
    foreach(model_file_name IN LISTS model_file_names)
    set(model_file "${CMAKE_BINARY_DIR}/${model_file_name}")
    list(APPEND model_files "${model_file}")
    if(NOT EXISTS "${model_file}")
    message("Downloading ${model_file_name}")
    file(DOWNLOAD
    "https://networkoptix.jfrog.io/artifactory/nx_open_integrations/opencv/${model_file_name}"
    "${model_file}"
    SHOW_PROGRESS
    )
    elseif()
    message("${model_file_name} already exits")
    endif()
    endforeach()

    set(CMAKE_CXX_STANDARD 17)
    set(CMAKE_CXX_EXTENSIONS OFF)

    set(CMAKE_CXX_VISIBILITY_PRESET hidden)
    set(CMAKE_POSITION_INDEPENDENT_CODE ON)

    if(UNIX)
    # In Linux, for the plugin .so library, set `rpath` to "$ORIGIN" and do not set `runpath`, thus
    # enabling the lookup of the dependencies in the plugin dir first.
    string(APPEND CMAKE_SHARED_LINKER_FLAGS " -Wl,--disable-new-dtags")
    endif()
    set(CMAKE_SKIP_BUILD_RPATH ON)
    set(CMAKE_BUILD_WITH_INSTALL_RPATH ON)
    set(CMAKE_INSTALL_RPATH "$ORIGIN")

    if(WIN32)
    set(API_EXPORT_MACRO "__declspec(dllexport)")
    elseif(UNIX)
    set(API_EXPORT_MACRO "__attribute__((visibility(\"default\")))")
    endif()

    #--------------------------------------------------------------------------------------------------
    # Define nx_kit lib, static.

    set(nxKitLibraryType "STATIC" CACHE STRING "" FORCE)
    set(nxKitWithTests "YES" CACHE STRING "" FORCE)

    add_subdirectory(${metadataSdkDir}/nx_kit ${CMAKE_CURRENT_BINARY_DIR}/nx_kit)

    #--------------------------------------------------------------------------------------------------
    # Define nx_sdk lib, static, depends on nx_kit.

    set(SDK_SRC_DIR ${metadataSdkDir}/src)
    file(GLOB_RECURSE SDK_SRC ${SDK_SRC_DIR}/*)

    add_library(nx_sdk STATIC ${SDK_SRC})
    target_include_directories(nx_sdk PUBLIC ${SDK_SRC_DIR})
    target_link_libraries(nx_sdk PRIVATE nx_kit)

    target_compile_definitions(nx_sdk PRIVATE NX_PLUGIN_API=${API_EXPORT_MACRO})

    #--------------------------------------------------------------------------------------------------
    # Define opencv_object_detection_analytics_plugin lib, dynamic, depends on nx_kit and nx_sdk.

    set(OPENCV_OBJECT_DETECTION_ANALYTICS_PLUGIN_SRC_DIR ${CMAKE_CURRENT_LIST_DIR}/src)
    file(GLOB_RECURSE OPENCV_OBJECT_DETECTION_ANALYTICS_PLUGIN_SRC
    ${OPENCV_OBJECT_DETECTION_ANALYTICS_PLUGIN_SRC_DIR}/*)

    add_library(opencv_object_detection_analytics_plugin SHARED
    ${OPENCV_OBJECT_DETECTION_ANALYTICS_PLUGIN_SRC})
    target_include_directories(opencv_object_detection_analytics_plugin PRIVATE
    ${OPENCV_ANALYTICS_PLUGIN_SRC_DIR} ${CONAN_INCLUDE_DIRS})
    set(CMAKE_EXE_LINKER_FLAGS " -static")
    target_link_libraries(opencv_object_detection_analytics_plugin
    nx_kit
    nx_sdk
    opencv::opencv
    -static-libgcc
    -static-libstdc++)

    target_compile_definitions(opencv_object_detection_analytics_plugin
    PRIVATE NX_PLUGIN_API=${API_EXPORT_MACRO}
    )
    0
    Comment actions Permalink
  • Avatar
    Mohamed Thasin

    Hello Andrey, 

    Thanks for the solution. I have completely replaced my existing CmakeLists.txt file with your CmakeLists.txt and placed model and plugin to proper directory. Now, I am not getting `GLIBCXX_3.4.26' not found error` . But a new error is occurred (undefined symbol: _ZN2cv3dnn14dnn4_v201909023Net8setInputERKNS_11_InputArrayERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEdRKNS_7Scalar_IdEE). Here is the error message. 

     

    {
    "description": "",
    "errorCode": "cannotLoadLibrary",
    "homeDir": "/opt/networkoptix-metavms/mediaserver/bin/plugins/opencv_object_detection_analytics_plugin",
    "instanceIndex": -1,
    "isActive": true,
    "libName": "opencv_object_detection_analytics_plugin",
    "libraryFilename": "/opt/networkoptix-metavms/mediaserver/bin/plugins/opencv_object_detection_analytics_plugin/libopencv_object_detection_analytics_plugin.so",
    "mainInterface": "undefined",
    "name": "",
    "nxSdkVersion": "",
    "optionality": "nonOptional",
    "resourceBindingInfo": [],
    "status": "notLoadedBecauseOfError",
    "statusMessage": "Failed loading Server Plugin [/opt/networkoptix-metavms/mediaserver/bin/plugins/opencv_object_detection_analytics_plugin/libopencv_object_detection_analytics_plugin.so] (): [cannotLoadLibrary]: Cannot load library /opt/networkoptix-metavms/mediaserver/bin/plugins/opencv_object_detection_analytics_plugin/libopencv_object_detection_analytics_plugin.so: (/opt/networkoptix-metavms/mediaserver/bin/plugins/opencv_object_detection_analytics_plugin/libopencv_object_detection_analytics_plugin.so: undefined symbol: _ZN2cv3dnn14dnn4_v201909023Net8setInputERKNS_11_InputArrayERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEdRKNS_7Scalar_IdEE)",
    "vendor": "",
    "version": ""
    }
    0
    Comment actions Permalink
  • Avatar
    Andrey Terentyev

    Mohamed,

    I've created a ticket in for your case.

    A solution will be posted here later on, once found.

    0
    Comment actions Permalink
  • Avatar
    Andrey Terentyev

    Hi,

    We have updated our repository in GitHub with several fixes.

    Please, rebase to the newest code version and check if the issue persists.

    0
    Comment actions Permalink

Please sign in to leave a comment.