How to share information between a CUDA gstreamer .so and a parent application

I am having trouble actively sharing a variable that is defined in a parent application with a gstreamer nvivafilter element that is doing CUDA processing.

I have written my own library that is used by nvivafilter to process a gstreamer pipeline (launched with gst_parse_launch() in the parent application). I have a variable defined as follows in my parent application:

volatile bool flying = false;

In my gstreamer CUDA source file,, I have this:

extern volatile bool flying;

So basically, the parent application starts, does some CPU processing then launches the gstreamer pipeline, streaming the H264 frames to another computer:

nvarguscamerasrc ! video/x-raw(memory:NVMM), width=(int)1280, height=(int)720, format=(string)NV12 ! nvivafilter cuda-process=true ! video/x-raw(memory:NVMM), format=(string)NV12 ! nvvidconv ! nvv4l2h264enc bitrate=400000 insert-sps-pps=1 maxperf-enable=1 ! h264parse ! rtph264pay pt=96 mtu=700 ! udpsink host= port=5000 sync=true -e

Just to be clear, if I swap my .so with the default .so built from the Nvidia examples, I see a green rectangle appear in the top left of the video as expected so my pipeline appears fine. I have set the environment variable GST_DEBUG=2 and I see the following text which tells me that my library is not running as expected:

0:00:05.188387870 11903   0x5595483430 WARN                    v4l2 gstv4l2object.c:2388:gst_v4l2_object_add_interlace_mode:0x559447a940 Failed to determine interlace mode
0:00:05.188514905 11903   0x5595483430 WARN                    v4l2 gstv4l2object.c:4476:gst_v4l2_object_probe_caps:<nvv4l2h264enc0:src> Failed to probe pixel aspect ratio with VIDIOC_CROPCAP: Unknown error -1
0:00:05.190544748 11903   0x5595483430 ERROR            nvivafilter gstnvivafilter.c:1446:gst_nvivafilter_start: gst_nvivafilter_start: open lib failed, /usr/lib/aarch64-linux-gnu/ undefined symbol: flying

Weirdly, the video from the camera is successfully streamed, so I assume that nvivafilter must be just doing a passthrough of the video data. There is a post here which describes using extern variables, however I cannot work out why they no longer work in my library. I could have sworn that 6 months ago it worked fine but maybe it didn’t.

Would anyone know why I cannot use extern variables in my .so file?

Does it work if you declare the variable in and expose it to the parent application?

1 Like

Yes, however this is inconvenient.

I was able to fix the resolving of this particular symbol by linking the main executable with the “-rdynamic” flag.

1 Like