GNOME Bugzilla – Bug 755864
C++ Linker problem for gst_app_src_push_sample
Last modified: 2015-09-30 11:24:03 UTC
Please describe the problem: GCC C++ Compliler can create the .0-files for .cpp-files with the function gst_app_src_push_sample, which is in gst/app/gstappsrc.h. But the GCC C++ Linker returns an 'undefined reference' for gst_app_src_push_sample. The linker has no problem finding other functions that are in gst/app/gstappsrc.h, like the function gst_app_src_push_buffer. The sample file ./gst-plugins-base/tests/examples/app/appsink-src2.c, which also contains gst_app_src_push_sample is build completely when building gstreamer-1.6.0. Steps to reproduce: 1. copy the file ./gst-plugins-base/tests/examples/app/appsink-src2.c to appsink-src2.cpp 2. make the file with the needed include path's and libraries Results: GCC C++ Linker returns: undefined reference to 'gst_app_src_push_sample' Does this happen every time? Yes. Other information: Linux 3.16.0-50-generic Ubuntu 14.04.1 x86_64
How are you invoking the compiler? I cannot reporoduce with the following program/compile switches. #include <gst/app/gstappsrc.h> int main (int argc, char *argv[]) { gst_app_src_push_sample (NULL, NULL); gst_app_src_push_buffer (NULL, NULL); return 0; } g++ $(pkg-config --cflags gstreamer-app-1.0) file.cpp $(pkg-config --libs gstreamer-app-1.0) gcc $(pkg-config --cflags gstreamer-app-1.0) file.cpp $(pkg-config --libs gstreamer-app-1.0) (Note that to solve the linker errors you would need to link against -lgstapp-1.0 which the pkg-config --libs gstreamer-app-1.0 gives you)
Created attachment 312418 [details] cpp-file of the appsink-src.c file The problem can be replicated by executing the following command on the file (the problem will occur during the second command): g++ -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/local/include/gstreamer-1.0 -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"appsink-src2.d" -MT"appsink-src2.d" -o "appsink-src2.o" "./appsink-src2.cpp" g++ -o "test" ./appsink-src2.o -lglib-2.0 -lgstbase-1.0 -lgobject-2.0 -lgstreamer-1.0 -lgstapp-1.0
Well, I am very sorry that I bothered you with this 'problem'. I use Eclipse and all gstreamer programs compiled fine until I used gst_app_src_push_sample. Solution to the problem is to add -L/user/local/lib/ as library search path to g++ (I found this out by looking at what pkg-config returns). Apparently not including /usr/local/lib/ as library search path works until you use new added functions.