lucasweb
lucasweb

Reputation: 1786

Unable to build GStreamer for Android Tutorials

I'm running into a number of issues attempting to build the GStreamer Android tutorials.

My environment is:

I am able to build and run the NDK samples both in Eclipse and from the command line.

I have downloaded http://cdn.gstreamer.com/android/arm/gstreamer-sdk-android-arm-debug-2012.11.tar.bz2 and added the GSTREAMER_SDK_ROOT_ANDROID environment variable to my .bash_profile.

When I try to build android-tutorial-1 via Eclipse I get the following error:

12:12:05 **** Incremental Build of configuration Default for project Tutorial1 ****
/apps/tools/android-ndk-r8d/ndk-build all 
jni/Android.mk:13: *** GSTREAMER_SDK_ROOT_ANDROID is not defined!.  Stop.

12:12:05 Build Finished (took 104ms)

I have tried adding GSTREAMER_SDK_ROOT_ANDROID to the C++ build variables in Eclispe but it makes no difference.

When I try to build via the command line I get the following error:

/bin/sh: pkg-config: command not found
/bin/sh: pkg-config: command not found
/bin/sh: pkg-config: command not found
GStreamer      : [GEN] => gst-build/gstreamer_android.c
GStreamer      : [COMPILE] => gst-build/gstreamer_android.c
gst-build/gstreamer_android.c:2:21: fatal error: gst/gst.h: No such file or directory
compilation terminated.
make: *** [gst-build/gstreamer_android.o] Error 1

What I can't figure out is gst/gst.h can not be resolved?

Upvotes: 8

Views: 9493

Answers (6)

CAMOBAP
CAMOBAP

Reputation: 5657

Here you faced with two problem

1. GSTREAMER_SDK_ROOT_ANDROID is not defined

Can be easily solved by set GSTREAMER_SDK_ROOT_ANDROID environment variable (in eclipse or Android.mk file) in my case I have specified this variable like this

GSTREAMER_VERSION   := 1.4.1
GSTREAMER_SDK_ROOT  := /Volumes/Data/Developers/Library/gstreamer-1.0-sdk-android/$(TARGET_ARCH_ABI)-$(APP_OPTIM)-$(GSTREAMER_VERSION)
  1. TARGET_ARCH_ABI - predefined variable (in my case armeabi-v7a)
  2. APP_OPTIM - predefined variable release or debug

In your case GSTREAMER_SDK_ROOT will be different of course but using predefined vars help a lot if you need support multiple archs

2. your pkg-confing is not in PATH

As you may see by default there is using sh shell

/bin/sh: pkg-config: command not found
/bin/sh: pkg-config: command not found
/bin/sh: pkg-config: command not found

It can't find pkg-config because initially PATH=/usr/bin:/bin:/usr/sbin:/sbin. In case when you installed pkg-config by brew on OSX it has been placed to /usr/local/bin

bash-3.2$ which pkg-config
/usr/local/bin/pkg-config

To fix PATH you can specify own shell

SHELL := PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin /bin/bash

This is not perfect solution but it works

Update for Gradle users

Since 2.2.0-alpha3 gradle android plugin support external build systems like this (add it in build.gradle inside android definition)

android { 
    ...
    externalNativeBuild {
        ndkBuild {
            path "${projectDir.absolutePath}/src/main/jni/Android.mk"
        }
    }
}

Don't forget cleanup jni.srcDirs because bad plugin will start first, to cleanup jni.srcDirs at runtime add

android { 
    ...
    task disableDefaultNdkBuild << {
        android.sourceSets.main.jni.srcDirs = []
        android.sourceSets.main.jniLibs.srcDir 'src/main/libs'
    }

    preBuild.dependsOn disableDefaultNdkBuild
}

Official guide now available https://gstreamer.freedesktop.org/documentation/tutorials/android/link-against-gstreamer.html

Upvotes: 10

johny3212
johny3212

Reputation: 1

@CAMOBAP Thank you for your post. It really help me. I am possible to build Android example in eclipse. Main problem was:

SHELL := PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin /bin/bash

Fo GSTREAMER_SDK_ROOT_ANDROID

  1. Right click on Project->Properties->C/C++ Build->Environment Add-> Name: GSTREAMER_SDK_ROOT_ANDROID Value: /Users/Your/Path/To/gstreamer-sdk-android-arm-release-2013.6 Add it also for Build Variables.

Next: You don't have to remove the ending forward slash from the line of code in MAC and you don't have to add Includes in Eclipse. These dependencies will be solved automatic after first build. Be sure that your Android SDK and NDK are running well in Eclipse. I also added SDK and NDK paths to:

nano .bash_profile

This is running on MAC. I also changed Manifest file to:

    android:minSdkVersion="xx"
    android:targetSdkVersion="xx" />

For Tutorial 5 from Android Gstreamer you need to add sdcard permission:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

Upvotes: 0

lucasweb
lucasweb

Reputation: 1786

I posted the above question on the GStreamer Android mailing list and got the following response:

Hi, Unfortunately we forgot to include pkg-config in this release for Mac OS X. You can download it from here: http://macpkg.sourceforge.net/

I used homebrew to install pkg-config and was able to build all of the Android Tutorials via the command line using ndk-build.

I still have a number of issues in Eclipse:

  1. * GSTREAMER_SDK_ROOT_ANDROID is not defined! - I can not get Eclipse to pick up this variable
  2. If I hard code the variable into the make file I then get /bin/sh: pkg-config: command not found - pkg-config is installed and working via the CLI

I believe some of the issues are related to Android Issue 33788 and I have attempted to resolve them using CDT 8.0.2 instead of CDT 8.10 but it did not solve either of the above issues.

I have worked around the problem for now by doing the following:

  1. Disabled CDT building for my project
  2. Building the NDK code using the CLI ndk-build
  3. Building and deploying the application to my device via Eclipse as normal

Upvotes: 5

user2937880
user2937880

Reputation: 1

I was facing the same problem but found nothing clear on internet. But somehow detail study of the problem led me to solve it.

To solve it you need to do the following steps in eclipse:

  1. Go to Windows->preferences->c/c++->build->Environment
  2. Click Add button on the right most of the window
  3. In the Name field enter "GSTREAMER_SDK_ROOT_ANDROID"
  4. In the Value field enter the location of the GStreamer SDK. In my case it was "C:\GStreamer_SDK". HERE IS THE PROBLEMMMM.... you need to use forward slash "/" instead of backward "\" to make it work properly. so my Gstreamer SDK location will look like this "C:/GStreamer_SDK"

Once you are done with it. You need to do some changes in the Android.mk file of your project.

Go to the following line

GSTREAMER_NDK_BUILD_PATH  := $(GSTREAMER_SDK_ROOT)/share/gst-android/ndk-build/

and remove the ending forward slash from the line of code. so it like will look like this.

GSTREAMER_NDK_BUILD_PATH  := $(GSTREAMER_SDK_ROOT)/share/gst-android/ndk-build

Save it and you are done with it!

If you don't remove the slash it will generate the path during build like this

c:/GStreamer_SDK/share/gst-android/ndk-build//gstreamer.mk

Double slashes are problem during build.

Now right click on project->clean Project

Now build it by right click on your project->build project.

If eclipse hangs while building just go to task manager and kill the make.exe service two times.

Run your project on your device or emulator. Have fun!

Upvotes: 0

Alston
Alston

Reputation: 1226

I use ADT with Eclipse and maybe you can define the GSTREAMER_SDK_ROOT_ANDROID as project-wise environment variable by following steps:

Project -> Properties -> C/C++ Build -> Environment -> Add

instead of define it in .mk file.

Upvotes: 0

Jeffersonchou
Jeffersonchou

Reputation: 41

for error1: jni/Android.mk:13: * GSTREAMER_SDK_ROOT_ANDROID is not defined!. Stop.

you can defind GSTREAMER_SDK_ROOT_ANDROID := XXXXX(your Gstreamer_Android_SDK Path) in your Android.mk files!

for error2: fatal error: gst/gst.h: No such file or directory

you can include the (Gstreamer_Android_SDK Path)/include/gstreamer0.10/ in the C/C++ General -> Paths and Symbols -> inlude!

Hope that would help:)

Upvotes: 4

Related Questions