OpenGL link error on Android with VTK 8.1.1, "undefined reference"(s) with OpenGL ES
I ported the old VtkVolumeRender android ant example project to Android Studio.
Sample output from a build attempt with some of the errors at the end:
Build command failed.
Error while executing process Android/Sdk/cmake/3.6.4111459/bin/cmake with arguments {--build
VtkAndroidVolumeRender/app/.externalNativeBuild/cmake/debug/x86_64 --target VolumeRender}
[1/2] Building CXX object CMakeFiles/VolumeRender.dir/RenderVolume.cpp.o
[2/2] Linking CXX shared library VtkAndroidVolumeRender/app/build/intermediates/cmake/debug/obj/x86_64/libVolumeRender.so
FAILED: : && Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ --target=x86_64-none-linux-android --gcc-toolchain=Android/Sdk/ndk-bundle/toolchains/x86_64-4.9/prebuilt/linux-x86_64 --sysroot=Android/Sdk/ndk-bundle/sysroot -fPIC -isystem Android/Sdk/ndk-bundle/sysroot/usr/include/x86_64-linux-android -D__ANDROID_API__=28 -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -Wa,--noexecstack -Wformat -Werror=format-security -std=c++11 -Wall -O0 -fno-limit-debug-info -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libatomic.a -nostdlib++ --sysroot Android/Sdk/ndk-bundle/platforms/android-28/arch-x86_64 -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--no-undefined -Wl,-z,noexecstack -Qunused-arguments -Wl,-z,relro -Wl,-z,now -shared -Wl,-soname,libVolumeRender.so -o VtkAndroidVolumeRender/app/build/intermediates/cmake/debug/obj/x86_64/libVolumeRender.so CMakeFiles/VolumeRender.dir/RenderVolume.cpp.o -landroid -llog vtkAndroidBuilds/VersionX/x86_64/CMakeExternals/Install/vtk-android/lib/libvtksys-8.1.a vtkAndroidBuilds/VersionX/x86_64/CMakeExternals/Install/vtk-android/lib/libvtkCommonCore-8.1.a vtkAndroidBuilds/VersionX/x86_64/CMakeExternals/Install/vtk-android/lib/libvtkCommonMath-8.1.a vtkAndroidBuilds/VersionX/x86_64/CMakeExternals/Install/vtk-android/lib/libvtkCommonMisc-8.1.a vtkAndroidBuilds/VersionX/x86_64/CMakeExternals/Install/vtk-android/lib/libvtkCommonSystem-8.1.a vtkAndroidBuilds/VersionX/x86_64/CMakeExternals/Install/vtk-android/lib/libvtkCommonTransforms-8.1.a vtkAndroidBuilds/VersionX/x86_64/CMakeExternals/Install/vtk-android/lib/libvtkCommonDataModel-8.1.a
... =========================================================== ...
vtk/Rendering/OpenGL2/vtkOpenGLCamera.cxx:77: error: undefined reference to 'glDrawBuffer'
vtk/Rendering/OpenGL2/vtkOpenGLPolyDataMapper.cxx:2355: error: undefined reference to 'glPointSize'
vtk/Rendering/OpenGL2/vtkOpenGLRenderer.cxx:451: error: undefined reference to 'glClearDepth'
from my CMakeLists.txt
add_library(VolumeRender SHARED ${sources})
target_link_libraries(VolumeRender PUBLIC
android
log
${VTK_LIBRARIES}
GLESv3
EGL
)
The OpenGL ES is a subset of OpenGL and APIs like 'glDrawBuffer' are not defined by OpenGL ES. It looks like the the vtk/ThirdParty/glew attempted to address this but it's not working.
This problem looks to be at the root of issues #16913 and #17237 as well