nvmsgbroker/proto-lib - unable to open shared library

I’m trying to write a custom protocol adaptor library (proto-lib) for nv message broker that just prints to the terminal or a file. However I get an error - unable to open shared library. Any ideas how to debug this?

Replacing my nvmsgbroker with a fakesink runs fine:

gst-launch-1.0 filesrc location=/root/deepstream_sdk_v4.0_x86_64/samples/streams/sample_720p.h264 ! h264parse ! nvv4l2decoder ! .sink_0 nvstreammux batch-size=1 width=1280 height=720 ! dsexample ! nvvideoconvert ! “video/x-raw(memory:NVMM), format=RGBA” ! nvdsosd ! nvmsgconv payload-type=PAYLOAD_DEEPSTREAM config=msgconv_config.txt ! fakesink

Setting pipeline to PAUSED …
Creating LL OSD context new
Pipeline is PREROLLING …
Creating LL OSD context new
Pipeline is PREROLLED …
Setting pipeline to PLAYING …
New clock: GstSystemClock
Got EOS from element “pipeline0”.
Execution ended after 0:00:04.189682099
Setting pipeline to PAUSED …
Setting pipeline to READY …
Setting pipeline to NULL …
Freeing pipeline …

Running with my custom proto-lib gives an error:

gst-launch-1.0 filesrc location=/root/deepstream_sdk_v4.0_x86_64/samples/streams/sample_720p.h264 ! h264parse ! nvv4l2decoder ! .sink_0 nvstreammux batch-size=1 width=1280 height=720 ! dsexample ! nvvideoconvert ! “video/x-raw(memory:NVMM), format=RGBA” ! nvdsosd ! nvmsgconv payload-type=PAYLOAD_DEEPSTREAM config=msgconv_config.txt ! nvmsgbroker proto-lib=libnvds_file_proto.so

Setting pipeline to PAUSED …

(gst-launch-1.0:153): GLib-CRITICAL **: 23:13:00.046: g_strrstr: assertion ‘haystack != NULL’ failed
ERROR: Pipeline doesn’t want to pause.
ERROR: from element /GstPipeline:pipeline0/GstNvMsgBroker:nvmsgbroker0: Could not initialize supporting library.
Additional debug info:
gstnvmsgbroker.c(303): gst_nvmsgbroker_start (): /GstPipeline:pipeline0/GstNvMsgBroker:nvmsgbroker0:
unable to open shared library
Setting pipeline to NULL …
Freeing pipeline …

I see the same error if I try to use the kafka example proto-lib.

Using GST_DEBUG=5 I see:
0:00:00.387869500 ^[[335m 9574^[[00m 0x55c550115c00 ^[[33;01mWARN ^[[00m ^[[00m nvmsgbroker gstnvmsgbroker.c:303:gst_nvmsgbroker_start:^[[00m error: unable to open shared library
0:00:00.387886961 ^[[335m 9574^[[00m 0x55c550115c00 ^[[37mDEBUG ^[[00m ^[[00;01;37;41m GST_MESSAGE gstelement.c:2114:gst_element_message_full_with_details:^[[00m start
0:00:00.387909311 ^[[335m 9574^[[00m 0x55c550115c00 ^[[36mINFO ^[[00m ^[[00;01;31;47m GST_ERROR_SYSTEM gstelement.c:2145:gst_element_message_full_with_details:^[[00m posting message: Could not initialize supporting library.
0:00:00.387941369 ^[[335m 9574^[[00m 0x55c550115c00 ^[[33;01mWARN ^[[00m ^[[00m structure gststructure.c:1832:priv_gst_structure_append_to_gstring:^[[00m No value transform to serialize field ‘gerror’ of type ‘GError’
0:00:00.387960925 ^[[335m 9574^[[00m 0x55c550115c00 ^[[37mDEBUG ^[[00m ^[[00;43m GST_BUS gstbus.c:318:gst_bus_post:^[[00m [msg 0x55c55046bd80] posting on bus error message: 0x55c55046bd80, time 99:99:99.999999999, seq-num 29, element ‘nvmsgbroker0’, GstMessageError, gerror=(GError)NULL, debug=(string)“gstnvmsgbroker.c(303):\ gst_nvmsgbroker_start\ ():\ /GstPipeline:pipeline0/GstNvMsgBroker:nvmsgbroker0:\012unable\ to\ open\ shared\ library”;
0:00:00.387974754 ^[[335m 9574^[[00m 0x55c550115c00 ^[[37mDEBUG ^[[00m ^[[00;01m bin gstbin.c:3717:gst_bin_handle_message_func:^[[00m [msg 0x55c55046bd80] handling child nvmsgbroker0 message of type error
0:00:00.387985510 ^[[335m 9574^[[00m 0x55c550115c00 ^[[37mDEBUG ^[[00m ^[[00;01m bin gstbin.c:3724:gst_bin_handle_message_func:^[[00m got ERROR message, unlocking state change
0:00:00.387996825 ^[[335m 9574^[[00m 0x55c550115c00 ^[[37mDEBUG ^[[00m ^[[00;01m bin gstbin.c:4054:gst_bin_handle_message_func:^[[00m posting message upward
0:00:00.388011911 ^[[335m 9574^[[00m 0x55c550115c00 ^[[33;01mWARN ^[[00m ^[[00m structure gststructure.c:1832:priv_gst_structure_append_to_gstring:^[[00m No value transform to serialize field ‘gerror’ of type ‘GError’
0:00:00.388027416 ^[[335m 9574^[[00m 0x55c550115c00 ^[[37mDEBUG ^[[00m ^[[00;43m GST_BUS gstbus.c:318:gst_bus_post:^[[00m [msg 0x55c55046bd80] posting on bus error message: 0x55c55046bd80, time 99:99:99.999999999, seq-num 29, element ‘nvmsgbroker0’, GstMessageError, gerror=(GError)NULL, debug=(string)“gstnvmsgbroker.c(303):\ gst_nvmsgbroker_start\ ():\ /GstPipeline:pipeline0/GstNvMsgBroker:nvmsgbroker0:\012unable\ to\ open\ shared\ library”;
0:00:00.388039290 ^[[335m 9574^[[00m 0x55c550115c00 ^[[37mDEBUG ^[[00m ^[[00;43m GST_BUS gstbus.c:357:gst_bus_post:^[[00m [msg 0x55c55046bd80] pushing on async queue
0:00:00.388064503 ^[[335m 9574^[[00m 0x55c550115c00 ^[[37mDEBUG ^[[00m ^[[00;43m GST_BUS gstbus.c:360:gst_bus_post:^[[00m [msg 0x55c55046bd80] pushed on async queue
0:00:00.388077215 ^[[335m 9574^[[00m 0x55c550115c00 ^[[37mDEBUG ^[[00m ^[[00;43m GST_BUS gstbus.c:353:gst_bus_post:^[[00m [msg 0x55c55046bd80] dropped
0:00:00.388089507 ^[[335m 9574^[[00m 0x55c550115c00 ^[[36mINFO ^[[00m ^[[00;01;31;47m GST_ERROR_SYSTEM gstelement.c:2172:gst_element_message_full_with_details:^[[00m posted error message: Could not initialize supporting library.
0:00:00.388101031 ^[[335m 9574^[[00m 0x55c550115c00 ^[[37mDEBUG ^[[00m ^[[00m basesink gstbasesink.c:5261:gst_base_sink_change_state:^[[00m failed to start
0:00:00.388112555 ^[[335m 9574^[[00m 0x55c550115c00 ^[[33;01mWARN ^[[00m ^[[00m basesink gstbasesink.c:5265:gst_base_sink_change_state:^[[00m error: Failed to start
0:00:00.388122473 ^[[335m 9574^[[00m 0x55c550115c00 ^[[37mDEBUG ^[[00m ^[[00;01;37;41m GST_MESSAGE gstelement.c:2114:gst_element_message_full_with_details:^[[00m start
0:00:00.388147058 ^[[335m 9574^[[00m 0x55c550115c00 ^[[36mINFO ^[[00m ^[[00;01;31;47m GST_ERROR_SYSTEM gstelement.c:2145:gst_element_message_full_with_details:^[[00m posting message: GStreamer error: state change failed and some element failed to post a proper error message with the reason for the failure.
0:00:00.388165846 ^[[335m 9574^[[00m 0x55c550115c00 ^[[33;01mWARN ^[[00m ^[[00m structure gststructure.c:1832:priv_gst_structure_append_to_gstring:^[[00m No value transform to serialize field ‘gerror’ of type ‘GError’

Hi,

Could you check if you are facing the same issue of this topic first?
https://devtalk.nvidia.com/default/topic/1044147/deepstream-sdk/ds3-0-deepstream_test4_app-cpp/

Thanks.

Thank you for the link, it looks interesting.

I was able to resolve the “unable to open shared library” Error by compiling my program with gcc instead of g++ and using pure C instead of C++.

To debug I built a modified version of the gst-nvmsgbroker plugin, I found that dlopen was returning an error and wrote out the error with dlerror. I recommend the source code be modified in future releases such that error returned by dlerror() is included in the error message from the following line:
GST_ELEMENT_ERROR (self, LIBRARY, INIT, (NULL), (“unable to open shared library”));

With my gst-launch-1.0 pipeline the nvds_msgapi_connect and nvds_msgapi_disconnect methods are called, but nvds_msgapi_send/nvds_msgapi_send_async/nvds_msgapi_do_work are not called, so it is not really useful in my launch pipeline. The examples all add data to the NvDsUserMeta in a probe - it looks like this is a requirement. I had hoped that object data could be read from the stream by a custom msg2p-lib, but it looks like this is not the case.