Tuesday, September 23, 2014

OPENGL NDK build problem using Android Studio on Mac OS

While building NDK application that consumes OPENGL, may not compile properly.
First make sure you have
ndk.dir= in local.settings
Also, the ndk folder has to be in PATH.
echo $PATH will show whats there in path and what is not.


You may get error like -
error: undefined reference to 'glGetUniformLocation'
error: undefined reference to 'glGetAttribLocation'
error: undefined reference to 'glUseProgram'
error: undefined reference to 'glBindTexture'
error: undefined reference to 'glUniform2f'
error: undefined reference to 'glVertexAttribPointer'
.......

I also saw that the Headers files for OPENGL framework in Mac OS was missing. You can update that using:
xcode-select --install

However, the error will not go.

The solution is:
Deactivate the ndk compilation from gradle by setting in build.gradle of your module. ( the inner one).
Place it inside under android tag:, below the build tool version

sourceSets.main {   
jni.srcDirs = []
    jniLibs.srcDir 'src/main/libs'
}
to be able to call ndk-build yourself and integrate libs from libs/.
Do a ndk-build at app/src/main, where jni folder resides.
The compiled jni code will be in 'src/main/libs'

Then install the app by gradle iD 

No comments:

Post a Comment