问题
I took the source of AndEngine from their git repo, downloaded a fresh AndroidStudio, sdk and ndk,imported it, and tried to creat a simple new empty GameActivity extends BaseGameActivity.
But I could not start it, cause I get the following errors:
/home/uhu/android-ndk-r9d/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: /home/uhu/AndroidStudioProjects/aaa/andEngine/build/intermediates/ndk/release/obj/local/armeabi-v7a/objs/andengine_shared//home/uhu/AndroidStudioProjects/aaa/andEngine/src/main/jni/src/GLES20Fix.o: in function Java_org_andengine_opengl_GLES20Fix_glVertexAttribPointer:/home/uhu/AndroidStudioProjects/aaa/andEngine/src/main/jni/src/GLES20Fix.c:9: error: undefined reference to 'glVertexAttribPointer'
/home/uhu/android-ndk-r9d/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: /home/uhu/AndroidStudioProjects/aaa/andEngine/build/intermediates/ndk/release/obj/local/armeabi-v7a/objs/andengine_shared//home/uhu/AndroidStudioProjects/aaa/andEngine/src/main/jni/src/GLES20Fix.o: in function Java_org_andengine_opengl_GLES20Fix_glDrawElements:/home/uhu/AndroidStudioProjects/aaa/andEngine/src/main/jni/src/GLES20Fix.c:13: error: undefined reference to 'glDrawElements'
Error:Execution failed for task ':andEngine:compileReleaseNdk'.
com.android.ide.common.internal.LoggedErrorException: Failed to run command: /home/uhu/android-ndk-r9d/ndk-build NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=/home/uhu/AndroidStudioProjects/aaa/andEngine/build/intermediates/ndk/release/Android.mk APP_PLATFORM=android-15 NDK_OUT=/home/uhu/AndroidStudioProjects/aaa/andEngine/build/intermediates/ndk/release/obj NDK_LIBS_OUT=/home/uhu/AndroidStudioProjects/aaa/andEngine/build/intermediates/ndk/release/lib APP_ABI=all Error Code: 2 Output: /home/uhu/android-ndk-r9d/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: /home/uhu/AndroidStudioProjects/aaa/andEngine/build/intermediates/ndk/release/obj/local/armeabi-v7a/objs/andengine_shared//home/uhu/AndroidStudioProjects/aaa/andEngine/src/main/jni/src/GLES20Fix.o: in function Java_org_andengine_opengl_GLES20Fix_glVertexAttribPointer:/home/uhu/AndroidStudioProjects/aaa/andEngine/src/main/jni/src/GLES20Fix.c:9: error: undefined reference to 'glVertexAttribPointer' /home/uhu/android-ndk-r9d/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: /home/uhu/AndroidStudioProjects/aaa/andEngine/build/intermediates/ndk/release/obj/local/armeabi-v7a/objs/andengine_shared//home/uhu/AndroidStudioProjects/aaa/andEngine/src/main/jni/src/GLES20Fix.o: in function Java_org_andengine_opengl_GLES20Fix_glDrawElements:/home/uhu/AndroidStudioProjects/aaa/andEngine/src/main/jni/src/GLES20Fix.c:13: error: undefined reference to 'glDrawElements' collect2: ld returned 1 exit status make: * [/home/uhu/AndroidStudioProjects/aaa/andEngine/build/intermediates/ndk/release/obj/local/armeabi-v7a/libandengine_shared.so] Error 1
Does anyone know how to fix this? Or if I'm just using the wrong tools, what can you recommend?
回答1:
I managed to get my project to compile. The problem seems to me that AS and ndk dont work together well yet. Any case check my blog on setting up the project:-
AS and AndEngine setup
回答2:
It seems to be easier using the official intellij version instead of android studio. And as both are very similar in use, it't doesn't really matter. Together with some ndk-build hints from the answer of lakshman5876, it finally worked very well. Thanks http://www.jetbrains.com/idea/
来源:https://stackoverflow.com/questions/24595344/andengine-android-studio-linker-error-during-build