Does metadata_sdk samples work with gcc9?

Answered

Comments

9 comments

  • Avatar
    Anton Babinov

    Hi James,

    I see plugin tab in camera settings.

    Most likely, mediaserver process didn't loaded the plugin. Could you please share steps on how you've compiled it and send me mediaserver's log file? I've tried building sample_analytics_plugin with version 9 and didn't find any issues.

    0
    Comment actions Permalink
  • Avatar
    James Yu

    Hi Anton,

    Here is the log before and after restarting mediaserver (so built with gcc9). This is log for .so built with gcc4.9.

    I build stub on ubuntu 18.04 with gcc9 + Qt Creator.

     Selection Path Priority Status
    ------------------------------------------------------------
    0 /usr/bin/gcc-4.9 49 auto mode
    1 /usr/bin/gcc-4.9 49 manual mode
    * 2 /usr/bin/gcc-9 9 manual mode

    Build by clicking [Build] > [Build Project "stub_analytics_plugin"]. Here is the build log in Qt Creator

    10:26:23: Running steps for project stub_analytics_plugin...
    10:26:23: Starting: "/usr/local/bin/cmake" --build . --target all
    [ 1%] Building CXX object nx_kit/CMakeFiles/nx_kit.dir/src/nx/kit/utils.cpp.o
    [ 2%] Building CXX object nx_kit/CMakeFiles/nx_kit.dir/src/nx/kit/debug.cpp.o
    [ 4%] Building CXX object nx_kit/CMakeFiles/nx_kit.dir/src/nx/kit/ini_config.cpp.o
    [ 5%] Building CXX object nx_kit/CMakeFiles/nx_kit.dir/src/nx/kit/output_redirector.cpp.o
    [ 6%] Building CXX object nx_kit/CMakeFiles/nx_kit.dir/src/nx/kit/test.cpp.o
    [ 8%] Building CXX object nx_kit/CMakeFiles/nx_kit.dir/src/nx/kit/json.cpp.o
    [ 9%] Linking CXX static library libnx_kit.a
    [ 9%] Built target nx_kit
    [ 10%] Building CXX object CMakeFiles/nx_sdk.dir/root/develop/metadata_sdk/src/nx/sdk/analytics/helpers/consuming_device_agent.cpp.o
    [ 12%] Building CXX object CMakeFiles/nx_sdk.dir/root/develop/metadata_sdk/src/nx/sdk/analytics/helpers/engine.cpp.o
    [ 13%] Building CXX object CMakeFiles/nx_sdk.dir/root/develop/metadata_sdk/src/nx/sdk/analytics/helpers/engine_info.cpp.o
    [ 15%] Building CXX object CMakeFiles/nx_sdk.dir/root/develop/metadata_sdk/src/nx/sdk/analytics/helpers/event_metadata.cpp.o
    [ 16%] Building CXX object CMakeFiles/nx_sdk.dir/root/develop/metadata_sdk/src/nx/sdk/analytics/helpers/event_metadata_packet.cpp.o
    [ 17%] Building CXX object CMakeFiles/nx_sdk.dir/root/develop/metadata_sdk/src/nx/sdk/analytics/helpers/metadata_types.cpp.o
    [ 19%] Building CXX object CMakeFiles/nx_sdk.dir/root/develop/metadata_sdk/src/nx/sdk/analytics/helpers/object_metadata.cpp.o
    [ 20%] Building CXX object CMakeFiles/nx_sdk.dir/root/develop/metadata_sdk/src/nx/sdk/analytics/helpers/object_metadata_packet.cpp.o
    [ 21%] Building CXX object CMakeFiles/nx_sdk.dir/root/develop/metadata_sdk/src/nx/sdk/analytics/helpers/object_track_best_shot_packet.cpp.o
    [ 23%] Building CXX object CMakeFiles/nx_sdk.dir/root/develop/metadata_sdk/src/nx/sdk/analytics/helpers/object_track_info.cpp.o
    [ 24%] Building CXX object CMakeFiles/nx_sdk.dir/root/develop/metadata_sdk/src/nx/sdk/analytics/helpers/pixel_format.cpp.o
    [ 26%] Building CXX object CMakeFiles/nx_sdk.dir/root/develop/metadata_sdk/src/nx/sdk/analytics/helpers/plugin.cpp.o
    [ 27%] Building CXX object CMakeFiles/nx_sdk.dir/root/develop/metadata_sdk/src/nx/sdk/analytics/helpers/timestamped_object_metadata.cpp.o
    [ 28%] Building CXX object CMakeFiles/nx_sdk.dir/root/develop/metadata_sdk/src/nx/sdk/helpers/attribute.cpp.o
    [ 30%] Building CXX object CMakeFiles/nx_sdk.dir/root/develop/metadata_sdk/src/nx/sdk/helpers/device_info.cpp.o
    [ 31%] Building CXX object CMakeFiles/nx_sdk.dir/root/develop/metadata_sdk/src/nx/sdk/helpers/error.cpp.o
    [ 32%] Building CXX object CMakeFiles/nx_sdk.dir/root/develop/metadata_sdk/src/nx/sdk/helpers/lib_context.cpp.o
    [ 34%] Building CXX object CMakeFiles/nx_sdk.dir/root/develop/metadata_sdk/src/nx/sdk/helpers/log_utils.cpp.o
    [ 35%] Building CXX object CMakeFiles/nx_sdk.dir/root/develop/metadata_sdk/src/nx/sdk/helpers/media_stream_statistics.cpp.o
    [ 36%] Building CXX object CMakeFiles/nx_sdk.dir/root/develop/metadata_sdk/src/nx/sdk/helpers/plugin_diagnostic_event.cpp.o
    [ 38%] Building CXX object CMakeFiles/nx_sdk.dir/root/develop/metadata_sdk/src/nx/sdk/helpers/settings_response.cpp.o
    [ 39%] Building CXX object CMakeFiles/nx_sdk.dir/root/develop/metadata_sdk/src/nx/sdk/helpers/string.cpp.o
    [ 41%] Building CXX object CMakeFiles/nx_sdk.dir/root/develop/metadata_sdk/src/nx/sdk/helpers/string_list.cpp.o
    [ 42%] Building CXX object CMakeFiles/nx_sdk.dir/root/develop/metadata_sdk/src/nx/sdk/helpers/string_map.cpp.o
    [ 43%] Building CXX object CMakeFiles/nx_sdk.dir/root/develop/metadata_sdk/src/nx/sdk/helpers/to_string.cpp.o
    [ 45%] Building CXX object CMakeFiles/nx_sdk.dir/root/develop/metadata_sdk/src/nx/sdk/helpers/uuid_helper.cpp.o
    [ 46%] Linking CXX static library libnx_sdk.a
    [ 46%] Built target nx_sdk
    [ 47%] Building CXX object CMakeFiles/stub_analytics_plugin.dir/src/nx/vms_server_plugins/analytics/stub/device_agent.cpp.o
    [ 49%] Building CXX object CMakeFiles/stub_analytics_plugin.dir/src/nx/vms_server_plugins/analytics/stub/engine.cpp.o
    [ 50%] Building CXX object CMakeFiles/stub_analytics_plugin.dir/src/nx/vms_server_plugins/analytics/stub/objects/abstract_object.cpp.o
    [ 52%] Building CXX object CMakeFiles/stub_analytics_plugin.dir/src/nx/vms_server_plugins/analytics/stub/objects/bicycle.cpp.o
    [ 53%] Building CXX object CMakeFiles/stub_analytics_plugin.dir/src/nx/vms_server_plugins/analytics/stub/objects/human_face.cpp.o
    [ 54%] Building CXX object CMakeFiles/stub_analytics_plugin.dir/src/nx/vms_server_plugins/analytics/stub/objects/pedestrian.cpp.o
    [ 56%] Building CXX object CMakeFiles/stub_analytics_plugin.dir/src/nx/vms_server_plugins/analytics/stub/objects/random.cpp.o
    [ 57%] Building CXX object CMakeFiles/stub_analytics_plugin.dir/src/nx/vms_server_plugins/analytics/stub/objects/stone.cpp.o
    [ 58%] Building CXX object CMakeFiles/stub_analytics_plugin.dir/src/nx/vms_server_plugins/analytics/stub/objects/vector2d.cpp.o
    [ 60%] Building CXX object CMakeFiles/stub_analytics_plugin.dir/src/nx/vms_server_plugins/analytics/stub/objects/vehicles.cpp.o
    [ 61%] Building CXX object CMakeFiles/stub_analytics_plugin.dir/src/nx/vms_server_plugins/analytics/stub/plugin.cpp.o
    [ 63%] Building CXX object CMakeFiles/stub_analytics_plugin.dir/src/nx/vms_server_plugins/analytics/stub/stub_analytics_plugin_ini.cpp.o
    [ 64%] Building CXX object CMakeFiles/stub_analytics_plugin.dir/src/nx/vms_server_plugins/analytics/stub/utils.cpp.o
    [ 65%] Linking CXX shared library libstub_analytics_plugin.so
    [ 65%] Built target stub_analytics_plugin
    [ 67%] Building CXX object CMakeFiles/stub_analytics_plugin_ut.dir/unit_tests/src/stub_analytics_plugin_ut.cpp.o
    [ 68%] Linking CXX executable stub_analytics_plugin_ut
    [ 68%] Built target stub_analytics_plugin_ut
    [ 69%] Building CXX object nx_kit/unit_tests/CMakeFiles/disabled_ini_config_ut.dir/__/src/nx/kit/ini_config.cpp.o
    [ 71%] Building CXX object nx_kit/unit_tests/CMakeFiles/disabled_ini_config_ut.dir/__/src/nx/kit/test.cpp.o
    [ 72%] Building CXX object nx_kit/unit_tests/CMakeFiles/disabled_ini_config_ut.dir/__/src/nx/kit/utils.cpp.o
    [ 73%] Building CXX object nx_kit/unit_tests/CMakeFiles/disabled_ini_config_ut.dir/src/ini_config_ut.cpp.o
    [ 75%] Building CXX object nx_kit/unit_tests/CMakeFiles/disabled_ini_config_ut.dir/src/disabled_ini_config_ut.cpp.o
    [ 76%] Linking CXX shared library libdisabled_ini_config_ut.so
    [ 76%] Built target disabled_ini_config_ut
    [ 78%] Building CXX object nx_kit/unit_tests/CMakeFiles/nx_kit_ut.dir/src/utils_ut.cpp.o
    [ 79%] Building CXX object nx_kit/unit_tests/CMakeFiles/nx_kit_ut.dir/src/output_redirector_ut.cpp.o
    [ 80%] Building CXX object nx_kit/unit_tests/CMakeFiles/nx_kit_ut.dir/src/debug_ut.cpp.o
    [ 82%] Building CXX object nx_kit/unit_tests/CMakeFiles/nx_kit_ut.dir/src/test_ut.cpp.o
    [ 83%] Building CXX object nx_kit/unit_tests/CMakeFiles/nx_kit_ut.dir/src/ini_config_ut.cpp.o
    [ 84%] Building CXX object nx_kit/unit_tests/CMakeFiles/nx_kit_ut.dir/src/ini.cpp.o
    [ 86%] Building C object nx_kit/unit_tests/CMakeFiles/nx_kit_ut.dir/src/ini_config_c_usage.c.o
    [ 87%] Building CXX object nx_kit/unit_tests/CMakeFiles/nx_kit_ut.dir/src/ini_config_c_ut.cpp.o
    [ 89%] Building CXX object nx_kit/unit_tests/CMakeFiles/nx_kit_ut.dir/src/json_ut.cpp.o
    [ 90%] Building CXX object nx_kit/unit_tests/CMakeFiles/nx_kit_ut.dir/src/flags_ut.cpp.o
    [ 91%] Building CXX object nx_kit/unit_tests/CMakeFiles/nx_kit_ut.dir/src/main.cpp.o
    [ 93%] Linking CXX executable nx_kit_ut
    [ 93%] Built target nx_kit_ut
    [ 94%] Building CXX object unit_tests/CMakeFiles/nx_sdk_ut.dir/src/ref_countable_ut.cpp.o
    [ 95%] Building CXX object unit_tests/CMakeFiles/nx_sdk_ut.dir/src/ptr_ut.cpp.o
    [ 97%] Building CXX object unit_tests/CMakeFiles/nx_sdk_ut.dir/src/uuid_helper_ut.cpp.o
    [ 98%] Building CXX object unit_tests/CMakeFiles/nx_sdk_ut.dir/src/main.cpp.o
    [100%] Linking CXX executable nx_sdk_ut
    [100%] Built target nx_sdk_ut
    10:28:15: The process "/usr/local/bin/cmake" exited normally.
    10:28:15: Elapsed time: 01:52.

    stub plugin .so file is copied to plugin folder

    -rwxr-xr-x 1 root root 1.6M Apr 20 15:11 libvivotek_analytics_plugin.so
    -rwxr-xr-x 1 root root 293K Apr 20 15:11 libvca_analytics_plugin.so
    -rwxr-xr-x 1 root root 350K Apr 20 15:11 libusb_camera_plugin.so
    -rwxr-xr-x 1 root root 265K Apr 20 15:11 libmjpeg_link_plugin.so
    -rwxr-xr-x 1 root root 531K Apr 20 15:11 libhikvision_analytics_plugin.so
    -rwxr-xr-x 1 root root 1.2M Apr 20 15:11 libhanwha_analytics_plugin.so
    -rwxr-xr-x 1 root root 35K Apr 20 15:11 libgeneric_rtsp_plugin.so
    -rwxr-xr-x 1 root root 84K Apr 20 15:11 libgeneric_multicast_plugin.so
    -rwxr-xr-x 1 root root 354K Apr 20 15:11 libdw_mx9_analytics_plugin.so
    -rwxr-xr-x 1 root root 338K Apr 20 15:11 libdw_mtt_analytics_plugin.so
    -rwxr-xr-x 1 root root 446K Apr 20 15:11 libdahua_analytics_plugin.so
    -rwxr-xr-x 1 root root 374K Apr 20 15:11 libbosch_analytics_plugin.so
    -rwxr-xr-x 1 root root 2.3M Apr 20 15:11 libaxis_analytics_plugin.so
    -rwxr-xr-x 1 root root 1.5M Aug 7 02:09 libsample_analytics_plugin.so
    drwxr-xr-x 2 root root 4.0K Aug 12 10:34 opencv_object_detection_analytics_plugin
    -rwxr-xr-x 1 root root 9.9M Aug 13 10:10 libstub_analytics_plugin.so

     

     

    0
    Comment actions Permalink
  • Avatar
    Anton Babinov

    Hi James,

    sorry for the delayed response. If the issue is still relevant for you, could you please send output of command:

    ldd libstub_analytics_plugin.so

    for both working and non-working stub plugin?

    0
    Comment actions Permalink
  • Avatar
    Andrey Terentyev

    Hello James Yu,

    By default, sample plugins are built with dynamic linking. That mean that standard libraries (libc, libgcc) are built dynamically.

    The point is that the Server is supplied with its own standard libraries. They are already loaded when it's started.

    Since you are using Ubuntu 18.04 with gcc9, the plugins are built supposed to use dynamic libc and libgcc from the 9th version of the compiler, which conflicts with the lib versions the Server has. I guess, that's the most probable reason. Search for PluginManager messages in the server log file.

    grep -i pluginmanager log_file.log

    Read more about the issue and solutions in the metadata_sdk/src/nx/sdk/dynamic_libraries.md

    In short, possible solutions are:

    1. Build plugins with static linking. In this case, you can use gcc9.

    2. Build plugins with dynamic linking preserving compatible lib versions.

    For the list of libs use this command:

    /opt/networkoptix/mediaserver/bin$ ldd mediaserver-bin

     

    0
    Comment actions Permalink
  • Avatar
    James Yu

    Hi Andrey,

    ldd output from libstub_analytics_plugin.so:

    # ldd libstub_analytics_plugin.so 
    linux-vdso.so.1 (0x00007ffc481fe000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fb207578000)
    libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fb20716b000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fb206dcd000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fb206bb5000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fb2067c4000)
    /lib64/ld-linux-x86-64.so.2 (0x00007fb207b41000)

    ldd output from the custom plugin built on top of opencv sample:

    # ldd libopencv_object_detection_analytics_plugin.so 
    linux-vdso.so.1 (0x00007ffce0732000)
    libkestrel_core.so.1 => /opt/networkoptix-metavms/mediaserver/bin/plugins/opencv_object_detection_analytics_plugin/./libkestrel_core.so.1 (0x00007fd32719b000)
    libkestrel.so.1 => /opt/networkoptix-metavms/mediaserver/bin/plugins/opencv_object_detection_analytics_plugin/./libkestrel.so.1 (0x00007fd326f78000)
    libkspark.so.1 => /opt/networkoptix-metavms/mediaserver/bin/plugins/opencv_object_detection_analytics_plugin/./libkspark.so.1 (0x00007fd326a55000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fd326836000)
    librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fd32662e000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fd326290000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fd325e9f000)
    /lib64/ld-linux-x86-64.so.2 (0x00007fd32828d000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fd325c9b000)
    libkestrel_aux.so.1 => /opt/networkoptix-metavms/mediaserver/bin/plugins/opencv_object_detection_analytics_plugin/./libkestrel_aux.so.1 (0x00007fd325951000)
    libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fd325544000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fd32532c000)

     

     

    0
    Comment actions Permalink
  • Avatar
    Andrey Terentyev

    What is the plugin you have the issue with?

    0
    Comment actions Permalink
  • Avatar
    James Yu

    libstub_analytics_plugin.so must be built with gcc4.9 to be loaded into nx meta server, won't be loaded when built with gcc9.

    libopencv_object_detection_analytics_plugin.so is built with gcc9 and works fine on nx meta server.

     

    0
    Comment actions Permalink
  • Avatar
    Andrey Terentyev

    Hi,

    As for opencv_object_detection_analytics_plugin, that's expected behavior.

    The code of opencv_object_detection_analytics_plugin was recently updated in the public repo taking into account the issue in question. The plugin is built with static linking since then.

    As for the stub_analytics_plugin of the Metadata SDK, it is expected behavior, too. It's our bad, and we're going to fix it in the nearest future.

    For now, here is a workaround.

    Update the metadata_sdk/samples/stub_analytics_plugin/CMakeLists.txt file like that (mind the lines in bold):

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

    set(STUB_ANALYTICS_PLUGIN_SRC_DIR ${CMAKE_CURRENT_LIST_DIR}/src)
    file(GLOB_RECURSE STUB_ANALYTICS_PLUGIN_SRC CONFIGURE_DEPENDS ${STUB_ANALYTICS_PLUGIN_SRC_DIR}/*)

    add_library(stub_analytics_plugin SHARED ${STUB_ANALYTICS_PLUGIN_SRC})
    target_include_directories(stub_analytics_plugin PRIVATE ${STUB_ANALYTICS_PLUGIN_SRC_DIR})
    set(CMAKE_EXE_LINKER_FLAGS " -static")
    target_link_libraries(stub_analytics_plugin
    PUBLIC nx_kit nx_sdk
    -static-libgcc
    -static-libstdc++
    ) #< Made PUBLIC for unit tests.

    and comment all lines following this part

    #--------------------------------------------------------------------------------------------------
    # Define stub_analytics_plugin_ut executable, depends on stub_analytics_plugin.

    Run this command:

    ./build_samples.sh --no-tests --release
    0
    Comment actions Permalink
  • Avatar
    James Yu

    Thank you Andrey, got it.

    0
    Comment actions Permalink

Please sign in to leave a comment.