Redirect: Exporting a gstreamer static function to a dll

Redirecting this issue from Build conversation to here, because it is a library issue.

I am building a wrapper of GStreamer to Delphi (pascal for windows, Linux, mac, ios & android)
in open source. For now only for window 64bit platform.
It is done by exporting (with visual studio) the c GStreamer functions to a G2D.dll
In Delphi you load G2D.dll and call GStreamer functions from Delphi.
The goal is to develop plugins in a fully easy object oriented framework
Most of the tutorials in the GStreamer docs are already implemented in this framework.
The problem is in going back to Basic tutorial 5, where there is a call to the function:
gst_video_overlay_set_window_handle(GstVideoOverlay* overlay, guintptr handle);
In a GStreamer c implementation, a procedure that calls this function must be declared static.

And a static procedure can’t be exported into a dll.

How can I bypass this issue?
Is there gstreamer-full.dll for windows?

I believe I don’t understand the part about the function calling a function having to be static. Can you extend?

Is there a gstreamer-full for windows?

I believe you can make a partial one using meson build system.

Thank you for your reply

function calling a function having to be static. Can you extend?
(This is also the first time I had this problem)
to demonstrate the problem, I made a small test program in a test.c file:
#include <gst/gst.h>

#include <gst/video/videooverlay.h>

static void test_function(GstVideoOverlay* overlay, guintptr handle) {

gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(overlay), handle);
}

The above test.c file gets compiled and build with no problem.

But if I take out the static declaration before test_function the file will not compile:
#include <gst/gst.h>

#include <gst/video/videooverlay.h>

void test_function(GstVideoOverlay* overlay, guintptr handle) {

gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(overlay), handle);
}
Now there are 2 errors in compilation:
Error 1 - LNK2019 unresolved external symbol __imp_gst_video_overlay_get_type referenced in function test_function.
As I understand error 1 (and I may be wrong): the _imp is a note that the compiler was not able to resolve gst_video_overlay_get_type that is defined in gtype.h

Error 2 LNK2019 unresolved external symbol __imp_gst_video_overlay_set_window_handle referenced in function test_function
As I understand error 2 (and again I may be wrong): the _imp is a note that the compiler was not able to resolve gst_video_overlay_set_window_handle that is defined in test.c

I believe you can make a partial one using meson build system.

Can you give a small example of how I should use meson for making a dll with some GStreamer functions?

Thanks Again

Ido

Thank you for your reply

function calling a function having to be static. Can you extend?
(This is also the first time I had this problem)
to demonstrate the problem, I made a small test program in a test.c file:
#include <gst/gst.h>

#include <gst/video/videooverlay.h>

static void test_function(GstVideoOverlay* overlay, guintptr handle) {

gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(overlay), handle);
}

The above test.c file gets compiled and build with no problem.

But if I take out the static declaration before test_function the file will not compile:
#include <gst/gst.h>

#include <gst/video/videooverlay.h>

void test_function(GstVideoOverlay* overlay, guintptr handle) {

gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(overlay), handle);
}
Now there are errors in compilation:



Error 1

|

LNK2019

|

unresolved external symbol __imp_gst_video_overlay_get_type referenced in function test_function

|

  • | - | - |

As I understand it (and I may be wrong): the _imp is a note that the compiler was not able to resolve gst_video_overlay_get_type that is defined in gtype.h



Error 2

|

LNK2019

|

unresolved external symbol __imp_gst_video_overlay_set_window_handle referenced in function test_function

|

  • | - | - |

As I understand it (and again I may be wrong): the _imp is a note that the compiler was not able to resolve gst_video_overlay_set_window_handle that is defined in test.c

I believe you can make a partial one using meson build system.

Can you give a small example of how I should use meson?

Thanks Again

Ido

(Attachment test.c is missing)

Could it just be that this is because this static function is unused and will be removed / optimised away and the problem will not appear because of that?

There is no requirement for a caller of GStreamer functions to have a particular type of visibility.

I think these “imp” linker errors mean that there’s a problem with your build setup - it is expecting to link libgstvideo dynamically here, and you’re not linking against the import library for libgstvideo (which will at runtime find+load the libgstvideo dll later). If that’s not what you meant to do you might be missing some defines in your app to force static linking (when including the gstreamer headers) (Just guessing here though)

You have to link against libgstvideo to call this function, that’s all.

Thank you so very much :slight_smile:
Without your direction I was very much lost.

In MS visual studio, added “gstvideo-1.0.lib”,
in Property configuration > Linker > Input > Additional dependencies

And your solution seems to solve the problem
Ido

Thank you so very much :slight_smile:
Without your direction I was very much lost.

In MS visual studio, added “gstvideo-1.0.lib”,
in Property configuration > Linker > Input > Additional dependencies

And your solution seems to solve the problem
Ido

1 Like