undefined reference of gst_init with default_library=static
I tried to build an example program with the gstreamer-full dynamic library under windows with mingw64.
I downloaded the sources and executed this command:
meson buildfull-dynamic -Ddefault_library=static -Dtools=disabled -Dtests=disabled && cd buildfull-dynamic && ninja && ninja install
It seemed to work fine.
Then I created this simple example project:
// pipeline.c
#include <gst/gst.h>
void InitGstreamerTest() {
gst_init(NULL, NULL);
}
//pipeline.h
void InitGstreamerTest();
//main.c
#include "pipeline.h"
int main(int argc, char *argv[]) {
InitGstreamerTest();
}
This test is just to see if it compiles.
When I execute the following command:
gcc -o pipeline.exe main.c pipeline.c $(pkg-config --libs --cflags gstreamer-full-1.0)
I get this error:
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\msys64\tmp\cchH4LXY.o:pipeline.c:(.text+0x1b): undefined referen
ce to `gst_init'
collect2.exe: error: ld returned 1 exit status
I searched for the gstreamer-full library:
find /mingw64 -type f -name "*gstreamer-full*"
/mingw64/bin/libgstreamer-full-1.0.dll
/mingw64/lib/libgstreamer-full-1.0.dll.a
/mingw64/lib/pkgconfig/gstreamer-full-1.0.pc
the content of gstreamer-full-1.0.pc is
cat /mingw64/lib/pkgconfig/gstreamer-full-1.0.pc
prefix=C:/msys64/mingw64
includedir=${prefix}/include
libdir=${prefix}/lib
Name: gstreamer-full-1.0
Description: gstreamer-full: gstreamer-full-1.0
Version: 1.23.0.1
Requires: glib-2.0 >= 2.62.0, gobject-2.0
Requires.private: gstcoreelements, gstcoretracers, gstadder, gstapp, gstaudioconvert, gstaudiomixer, gstaudiorate, gstaudioresample, gstaudiotestsrc, gstcompositor, gstdsd, gstencoding, gstgio, gstoverlaycomposition, gstpbtypes, gstplayback, gstrawparse, gstsubparse, gsttcp, gsttypefindfunctions, gstvideoconvertscale, gstvideorate, gstvideotestsrc, gstvolume, gstopengl, gstogg, gstopus, gstpango, gstvorbis, gstalpha, gstalphacolor, gstapetag, gstaudiofx, gstaudioparsers, gstauparse, gstautodetect, gstavi, gstcutter, gstnavigationtest, gstdebug, gstdeinterlace, gstdtmf, gsteffectv, gstequalizer, gstflv, gstflxdec, gstgoom, gstgoom2k1, gsticydemux, gstid3demux, gstimagefreeze, gstinterleave, gstisomp4, gstalaw, gstmulaw, gstlevel, gstmatroska, gstmonoscope, gstmultifile, gstmultipart, gstreplaygain, gstrtp, gstrtpmanager, gstrtsp, gstshapewipe, gstsmpte, gstspectrum, gstudp, gstvideobox, gstvideocrop, gstvideofilter, gstvideomixer, gstwavenc, gstwavparse, gstxingmux, gsty4menc, gstdirectsound, gstwaveform, gstcairo, gstjack, gstjpeg, gstlame, gstdv, gstpng, gstnice, gstaccurip, gstadpcmdec, gstadpcmenc, gstaiff, gstasfmux, gstaudiobuffersplit, gstaudiofxbad, gstaudiomixmatrix, gstaudiolatency, gstaudiovisualizers, gstautoconvert, gstbayer, gstcamerabin, gstcodecalpha, gstcodectimestamper, gstcoloreffects, gstdebugutilsbad, gstdvbsubenc, gstdvbsuboverlay, gstdvdspu, gstfaceoverlay, gstfestival, gstfieldanalysis, gstfreeverb, gstfrei0r, gstgaudieffects, gstgdp, gstgeometrictransform, gstid3tag, gstinter, gstinterlace, gstivfparse, gstivtc, gstjp2kdecimator, gstjpegformat, gstrfbsrc, gstmidi, gstmpegpsdemux, gstmpegpsmux, gstmpegtsdemux, gstmpegtsmux, gstmxf, gstnetsim, gstrtponvif, gstpcapparse, gstpnm, gstproxy, gstlegacyrawparse, gstremovesilence, gstrist, gstrtmp2, gstrtpmanagerbad, gstsdpelem, gstsegmentclip, gstsiren, gstsmooth, gstspeed, gstsubenc, gstswitchbin, gsttimecode, gsttranscode, gstvideofiltersbad, gstvideoframe_audiolevel, gstvideoparsersbad, gstvideosignal, gstvmnc, gsty4mdec, gstamfcodec, gstd3d11, gstd3d, gstdecklink, gstdirectsoundsrc, gstdwrite, gstipcpipeline, gstnvcodec, gstqsv, gstva, gstwasapi, gstwin32ipc, gstwinks, gstwinscreencap, gstaes, gstbz2, gstclosedcaption, gstcodec2json, gstcolormanagement, gstdash, gstdtls, gstfdkaac, gsthls, gstmicrodns, gstopenh264, gstopenjpeg, gstopusparse, gstsctp, gstsmoothstreaming, gstsrtp, gstttmlsubs, gstwebrtc, gstwebp, gstasf, gstdvdlpcmdec, gstdvdsub, gstrealmedia, gstlibav, gstrtspclientsink, gstnle, gstges, gmodule-no-export-2.0
Libs: -L${libdir} -lgstreamer-full-1.0
Libs.private: -Wl,--undefined=gst_init_static_plugins -lm -lws2_32
Cflags: -I${includedir}/gstreamer-1.0
And I checked if the Symbol is available in the file /mingw64/bin/libgstreamer-full-1.0.dll
nm /mingw64/bin/libgstreamer-full-1.0.dll | grep gst_init
00000002efe9f420 T gst_init
00000002efe9f300 T gst_init_check
00000002efe9f260 T gst_init_get_option_group
00000002efe91370 T gst_init_static_plugins
00000002f26ad354 b gst_initialized
So I think it should work !?
Does anyone have an Idea what I am doing wrong?