<br>Mates, I am having a issue when trying to compile a simple code that should work without problems. <br>I have it running in other machines, but I can't figure out what it might be.<br><br><br>This is the output:<br>
<br>bash-3.1# gcc -Wall $(pkg-config --cflags --libs gstreamer-0.10) spectrum.c <br>/tmp/cccrQH9p.o: In function `bus_call':<br>spectrum.c:(.text+0xd): undefined reference to `gst_message_get_type'<br>spectrum.c:(.text+0x64): undefined reference to `gst_message_parse_error'<br>
/tmp/cccrQH9p.o: In function `on_pad_added':<br>spectrum.c:(.text+0xdd): undefined reference to `gst_element_get_static_pad'<br>spectrum.c:(.text+0xf1): undefined reference to `gst_pad_link'<br>spectrum.c:(.text+0xff): undefined reference to `gst_object_unref'<br>
/tmp/cccrQH9p.o: In function `main':<br>spectrum.c:(.text+0x12b): undefined reference to `gst_init'<br>spectrum.c:(.text+0x17c): undefined reference to `gst_pipeline_new'<br>spectrum.c:(.text+0x194): undefined reference to `gst_element_factory_make'<br>
spectrum.c:(.text+0x1ac): undefined reference to `gst_element_factory_make'<br>spectrum.c:(.text+0x1c4): undefined reference to `gst_element_factory_make'<br>spectrum.c:(.text+0x1dc): undefined reference to `gst_element_factory_make'<br>
spectrum.c:(.text+0x1f4): undefined reference to `gst_element_factory_make'<br>spectrum.c:(.text+0x26c): undefined reference to `gst_pipeline_get_type'<br>spectrum.c:(.text+0x285): undefined reference to `gst_pipeline_get_bus'<br>
spectrum.c:(.text+0x29e): undefined reference to `gst_bus_add_watch'<br>spectrum.c:(.text+0x2ac): undefined reference to `gst_object_unref'<br>spectrum.c:(.text+0x2b4): undefined reference to `gst_bin_get_type'<br>
spectrum.c:(.text+0x2de): undefined reference to `gst_bin_add_many'<br>spectrum.c:(.text+0x2ef): undefined reference to `gst_element_link'<br>spectrum.c:(.text+0x302): undefined reference to `gst_element_link_many'<br>
spectrum.c:(.text+0x34e): undefined reference to `gst_element_set_state'<br>spectrum.c:(.text+0x38c): undefined reference to `gst_element_set_state'<br>spectrum.c:(.text+0x3a4): undefined reference to `gst_object_get_type'<br>
spectrum.c:(.text+0x3bd): undefined reference to `gst_object_unref'<br>collect2: ld returned 1 exit status<br><br><br><br clear="all">I have the PKG_CONFIG_PATH duly configured and gstreamer-0.10 libraries are installed. What am I missing here??????<br>
<br>This is the code:<br><br>#include <gst/gst.h><br>#include <glib.h><br><br><br>static gboolean<br>bus_call (GstBus *bus,<br> GstMessage *msg,<br> gpointer data)<br>{<br> GMainLoop *loop = (GMainLoop *) data;<br>
<br> switch (GST_MESSAGE_TYPE (msg)) {<br><br> case GST_MESSAGE_EOS:<br> g_print ("End of stream\n");<br> g_main_loop_quit (loop);<br> break;<br><br> case GST_MESSAGE_ERROR: {<br> gchar *debug;<br>
GError *error;<br><br> gst_message_parse_error (msg, &error, &debug);<br> g_free (debug);<br><br> g_printerr ("Error: %s\n", error->message);<br> g_error_free (error);<br><br>
g_main_loop_quit (loop);<br> break;<br> }<br> default:<br> break;<br> }<br><br> return TRUE;<br>}<br><br><br>static void<br>on_pad_added (GstElement *element,<br> GstPad *pad,<br> gpointer data)<br>
{<br> GstPad *sinkpad;<br> GstElement *decoder = (GstElement *) data;<br><br> /* We can now link this pad with the vorbis-decoder sink pad */<br> g_print ("Dynamic pad created, linking demuxer/decoder\n");<br>
<br> sinkpad = gst_element_get_static_pad (decoder, "sink");<br><br> gst_pad_link (pad, sinkpad);<br><br> gst_object_unref (sinkpad);<br>}<br><br><br><br>int<br>main (int argc,<br> char *argv[])<br>{<br>
GMainLoop *loop;<br><br> GstElement *pipeline, *source, *demuxer, *decoder, *conv, *sink;<br> GstBus *bus;<br><br> /* Initialisation */<br> gst_init (&argc, &argv);<br><br> loop = g_main_loop_new (NULL, FALSE);<br>
<br><br> /* Check input arguments */<br> if (argc != 2) {<br> g_printerr ("Usage: %s <Ogg/Vorbis filename>\n", argv[0]);<br> return -1;<br> }<br><br><br> /* Create gstreamer elements */<br> pipeline = gst_pipeline_new ("audio-player");<br>
source = gst_element_factory_make ("filesrc", "file-source");<br> demuxer = gst_element_factory_make ("oggdemux", "ogg-demuxer");<br> decoder = gst_element_factory_make ("vorbisdec", "vorbis-decoder");<br>
conv = gst_element_factory_make ("audioconvert", "converter");<br> sink = gst_element_factory_make ("autoaudiosink", "audio-output");<br><br> if (!pipeline || !source || !demuxer || !decoder || !conv || !sink) {<br>
g_printerr ("One element could not be created. Exiting.\n");<br> return -1;<br> }<br><br> /* Set up the pipeline */<br><br> /* we set the input filename to the source element */<br> g_object_set (G_OBJECT (source), "location", argv[1], NULL);<br>
<br> /* we add a message handler */<br> bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));<br> gst_bus_add_watch (bus, bus_call, loop);<br> gst_object_unref (bus);<br><br> /* we add all elements into the pipeline */<br>
/* file-source | ogg-demuxer | vorbis-decoder | converter | alsa-output */<br> gst_bin_add_many (GST_BIN (pipeline),<br> source, demuxer, decoder, conv, sink, NULL);<br><br> /* we link the elements together */<br>
/* file-source -> ogg-demuxer ~> vorbis-decoder -> converter -> alsa-output */<br> gst_element_link (source, demuxer);<br> gst_element_link_many (decoder, conv, sink, NULL);<br> g_signal_connect (demuxer, "pad-added", G_CALLBACK (on_pad_added), decoder);<br>
<br> /* note that the demuxer will be linked to the decoder dynamically.<br> The reason is that Ogg may contain various streams (for example<br> audio and video). The source pad(s) will be created at run time,<br>
by the demuxer when it detects the amount and nature of streams.<br> Therefore we connect a callback function which will be executed<br> when the "pad-added" is emitted.*/<br><br><br> /* Set the pipeline to "playing" state*/<br>
g_print ("Now playing: %s\n", argv[1]);<br> gst_element_set_state (pipeline, GST_STATE_PLAYING);<br><br><br> /* Iterate */<br> g_print ("Running...\n");<br> g_main_loop_run (loop);<br><br><br> /* Out of the main loop, clean up nicely */<br>
g_print ("Returned, stopping playback\n");<br> gst_element_set_state (pipeline, GST_STATE_NULL);<br><br> g_print ("Deleting pipeline\n");<br> gst_object_unref (GST_OBJECT (pipeline));<br><br> return 0;<br>
}<br><br><br>Tks so much!<br>