<div dir="ltr">
<p>Hello! My goal is to use functions such as gst_app_sink_pull_sample (I am 
trying to run an old android application). But it gives linker errors.</p>
<p>First of all, to check if Gstreamer and NDK are correctly configured, I run all 5 tutorials given by GStreamer and those compiled and run without any problem.</p>
<p>GStreamer used: 1.8.0 for android / NDK: 21.0.6113669 / Android Studio: 4.0.1</p>
<p>So, to simplify the problem I just added that function to tutorial-1 
to test if the problem comes with the linker or with the code. All the 
code is almost the same as the tutorial-1, with the exception of three 
lines (in addition of gst/app/app.h), 
I just added this code in the JNI_OnLoad functi<span style="font-family:arial,sans-serif">on in tutorial-1.<code>c</code></span>

:</p><p>
</p><pre class="gmail-default gmail-s-code-block gmail-hljs gmail-lisp"><code>    GstAppSink *sink = NULL<span class="gmail-hljs-comment">;</span>
    GstSample* sample = gst_app_sink_pull_sample(<span class="gmail-hljs-name">sink</span>)<span class="gmail-hljs-comment">;</span>
    GstBuffer* buffer = gst_sample_get_buffer(<span class="gmail-hljs-name">sample</span>)<span class="gmail-hljs-comment">;</span></code></pre>



<div><br></div><div></div><div><code>
<span style="font-family:arial,sans-serif">Because linker errors can happen when a library is missing, I included all of them in the Android.mk:

</span></code></div><div><code>
</code><pre class="gmail-default gmail-s-code-block gmail-hljs gmail-makefile"><code>GSTREAMER_PLUGINS := <span class="gmail-hljs-variable">$(GSTREAMER_PLUGINS_CORE)</span> <span class="gmail-hljs-variable">$(GSTREAMER_PLUGINS_PLAYBACK)</span> <span class="gmail-hljs-variable">$(GSTREAMER_PLUGINS_CODECS)</span> <span class="gmail-hljs-variable">$(GSTREAMER_PLUGINS_CODECS_RESTRICTED)</span> <span class="gmail-hljs-variable">$(GSTREAMER_PLUGINS_NET)</span> <span class="gmail-hljs-variable">$(GSTREAMER_PLUGINS_SYS)</span></code></pre></div><div><br></div><div>
However, it still gives a linker error. The full stack is:

</div><div>
<pre class="gmail-default gmail-s-code-block gmail-hljs gmail-sql"><code>Build command failed.
Error while executing process /home/tech/Android/Sdk/ndk/21.0.6113669/ndk-build <span class="gmail-hljs-keyword">with</span> arguments {NDK_PROJECT_PATH=<span class="gmail-hljs-literal">null</span> APP_BUILD_SCRIPT=/home/tech/StudioProjects/gst-docs/examples/tutorials/android/android-tutorial<span class="gmail-hljs-number">-1</span>/jni/Android.mk NDK_APPLICATION_MK=/home/tech/StudioProjects/gst-docs/examples/tutorials/android/android-tutorial<span class="gmail-hljs-number">-1</span>/jni/Application.mk APP_ABI=armeabi-v7a NDK_ALL_ABIS=armeabi-v7a NDK_DEBUG=<span class="gmail-hljs-number">1</span> APP_PLATFORM=android<span class="gmail-hljs-number">-16</span> NDK_OUT=/home/tech/StudioProjects/gst-docs/examples/tutorials/android/android-tutorial<span class="gmail-hljs-number">-1</span>/<span class="gmail-hljs-keyword">build</span>/intermediates/ndkBuild/debug/obj NDK_LIBS_OUT=/home/tech/StudioProjects/gst-docs/examples/tutorials/android/android-tutorial<span class="gmail-hljs-number">-1</span>/<span class="gmail-hljs-keyword">build</span>/intermediates/ndkBuild/debug/lib NDK_APPLICATION_MK=jni/Application.mk GSTREAMER_JAVA_SRC_DIR=src GSTREAMER_ROOT_ANDROID=/home/tech/StudioProjects/ci_host_android/app/src/<span class="gmail-hljs-keyword">main</span>/android_libs/gstreamer GSTREAMER_ASSETS_DIR=src/assets /home/tech/StudioProjects/gst-docs/examples/tutorials/android/android-tutorial<span class="gmail-hljs-number">-1</span>/<span class="gmail-hljs-keyword">build</span>/intermediates/ndkBuild/debug/obj/<span class="gmail-hljs-keyword">local</span>/armeabi-v7a/libtutorial<span class="gmail-hljs-number">-1.</span>so}
[armeabi-v7a] Compile thumb  : tutorial<span class="gmail-hljs-number">-1</span> <= tutorial<span class="gmail-hljs-number">-1.</span>c
GStreamer      : [GEN] => gst-<span class="gmail-hljs-keyword">build</span>-armeabi-v7a/gstreamer_android.c
GStreamer      : [COMPILE] => gst-<span class="gmail-hljs-keyword">build</span>-armeabi-v7a/gstreamer_android.c
GStreamer      : [<span class="gmail-hljs-keyword">LINK</span>] => gst-<span class="gmail-hljs-keyword">build</span>-armeabi-v7a/libgstreamer_android.so
Done mkdir
Done cp
[armeabi-v7a] <span class="gmail-hljs-keyword">Prebuilt</span>       : libgstreamer_android.so <= gst-<span class="gmail-hljs-keyword">build</span>-armeabi-v7a/
[armeabi-v7a] SharedLibrary  : libtutorial<span class="gmail-hljs-number">-1.</span>so
jni/tutorial<span class="gmail-hljs-number">-1.</span>c:<span class="gmail-hljs-number">28</span>: <span class="gmail-hljs-keyword">error</span>: undefined <span class="gmail-hljs-keyword">reference</span> <span class="gmail-hljs-keyword">to</span> <span class="gmail-hljs-string">'gst_app_sink_pull_sample'</span>
clang++: <span class="gmail-hljs-keyword">error</span>: linker command <span class="gmail-hljs-keyword">failed</span> <span class="gmail-hljs-keyword">with</span> <span class="gmail-hljs-keyword">exit</span> code <span class="gmail-hljs-number">1</span> (<span class="gmail-hljs-keyword">use</span> -v <span class="gmail-hljs-keyword">to</span> see invocation)
make: *** [/home/tech/Android/Sdk/ndk/<span class="gmail-hljs-number">21.0</span><span class="gmail-hljs-number">.6113669</span>/<span class="gmail-hljs-keyword">build</span>/core/<span class="gmail-hljs-keyword">build</span>-<a href="http://binary.mk">binary.mk</a>:<span class="gmail-hljs-number">725</span>: /home/tech/StudioProjects/gst-docs/examples/tutorials/android/android-tutorial<span class="gmail-hljs-number">-1</span>/<span class="gmail-hljs-keyword">build</span>/intermediates/ndkBuild/debug/obj/<span class="gmail-hljs-keyword">local</span>/armeabi-v7a/libtutorial<span class="gmail-hljs-number">-1.</span>so] <span class="gmail-hljs-keyword">Error</span> <span class="gmail-hljs-number">1<br><br></span></code></pre><pre class="gmail-default gmail-s-code-block gmail-hljs gmail-sql"><code><span class="gmail-hljs-number"><font face="arial,sans-serif">Another idea was that probably those functions (gst_app_sink_*) were not in the library (libgstapp-1.0.a), so I run the command nm to know the exported functions inside the library. However, the library contains those functions, so the only possibility is that the library is not being imported. I also tested other functions (for example: get_app_stream_type_get_type) inside that library and none of those work (the functions are recognized by the headers, but not by the linker). Then, probably this is a bug or I am missing something.</font><br></span></code></pre><pre class="gmail-default gmail-s-code-block gmail-hljs gmail-sql"><code><span class="gmail-hljs-number"><span style="font-family:arial,sans-serif">Regards</span><br></span></code></pre><pre class="gmail-default gmail-s-code-block gmail-hljs gmail-sql"><code><span class="gmail-hljs-number"><br></span></code></pre>

</div></div>