Hello everyone, when I compiled the vtk-android (arm64-v8a NDK 27.0.11902837) static library, I was prompted to replace ALooper_pollAll() with ALooper_pollOnce(), and I did so and compiled successfully.
Now I want to publish VTK to Android. But I don’t want to use android studio, I just use QT Creator to compile it. QT compilation Android requires the use of Qt Quick engineering,
However, in the CMakeLists.txt, following the VTK example configuration will give an error, which is completely new to this aspect. I wonder if I can do that. How should I modify it if I can.
Hello,
Please, post the CMake error message.
best,
PC
hello,This is my cmakelists.txt
cmake_minimum_required(VERSION 3.16)
project(VTKApp VERSION 0.1 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(VTK_DIR "D:/bin/AVTK/CMakeExternals/Install/vtk-android/lib/cmake/vtk-9.3")
find_package(Qt6 6.4 REQUIRED COMPONENTS Quick)
if (CMAKE_BINARY_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
message(FATAL_ERROR "VTK Android does not support in-source builds :) .")
endif ()
find_package(VTK REQUIRED )
qt_standard_project_setup()
qt_add_executable(appVTKApp
main.cpp
)
qt_add_qml_module(appVTKApp
URI VTKApp
VERSION 1.0
QML_FILES
Main.qml
)
# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
# If you are developing for iOS or macOS you should consider setting an
# explicit, fixed bundle identifier manually though.
set_target_properties(appVTKApp PROPERTIES
# MACOSX_BUNDLE_GUI_IDENTIFIER com.example.appVTKApp
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
MACOSX_BUNDLE TRUE
WIN32_EXECUTABLE TRUE
)
if(NOT VTK_FOUND)
message(SEND_ERROR "VTK NOT FOUND:${VTK_NOT_FOUND_MESSAGE}")
return()
endif()
target_link_libraries(appVTKApp
PRIVATE Qt6::Quick ${VTK_LIBRARIES}
)
vtk_module_autoinit(
TARGETS appVTKApp
MODULES ${VTK_LIBRARIES})
include(GNUInstallDirs)
install(TARGETS appVTKApp
BUNDLE DESTINATION .
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
I just #include<vtkRenderWindow.h> and I get the following error。Please, how do I go about using the static library of vtk-android。
[1/11 4.5/sec] Automatic MOC and UIC for target appVTKApp
[2/10 7.6/sec] Running AUTOMOC file extraction for target appVTKApp
[3/5 0.8/sec] Building CXX object CMakeFiles/appVTKApp.dir/main.cpp.o
[4/5 0.8/sec] Linking CXX shared module libappVTKApp_arm64-v8a.so
FAILED: libappVTKApp_arm64-v8a.so
C:\WINDOWS\system32\cmd.exe /C "cd . && D:\AppData\Android\Sdk\ndk\27.0.11902837\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe --target=aarch64-none-linux-android23 --sysroot=D:/AppData/Android/Sdk/ndk/27.0.11902837/toolchains/llvm/prebuilt/windows-x86_64/sysroot -fPIC -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fexceptions -frtti -stdlib=libc++ -O3 -DNDEBUG -Wl,--build-id=sha1 -Wl,--no-rosegment -Wl,--no-undefined-version -Wl,--fatal-warnings -Wl,--gc-sections -Qunused-arguments -Wl,--no-undefined -shared -o libappVTKApp_arm64-v8a.so @CMakeFiles\appVTKApp.rsp && cd ."
ld.lld: error: undefined symbol: __write_chk
>>> referenced by ProcessUNIX.c
>>> ProcessUNIX.c.o:(kwsysProcessCreate) in archive D:/bin/AVTK/CMakeExternals/Install/vtk-android/lib/libvtksys-9.3.a
>>> referenced by ProcessUNIX.c
>>> ProcessUNIX.c.o:(kwsysProcessChildErrorExit) in archive D:/bin/AVTK/CMakeExternals/Install/vtk-android/lib/libvtksys-9.3.a
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
I tested vtkVersion, vtkMath and I didn’t get the problem, I guess it’s a problem with files like vtkRenderer, vtkRenderWindow, vtkAndroidRenderWindowInteractor, is it that the NDK version is too high?
Hello,
Please, take a look here: [BUG] undefined reference to `__write_chk' · Issue #1179 · android/ndk · GitHub for some hints of what may be amiss in your build.
regards,
PC
Thank you very much, I’ll try it later
Hello,I modified the ANDROID_PLATFORM to android-34 in CMake in qt creator and this issue was solved. However, when executing vtkRenderer::Render() or vtkRenderWindow::Render(), sigment faul occurs and crashes.
This is called directly in the main function of qt quick:
I libappVTKreldeb_arm64-v8a.so: vtkNew<vtkRenderWindow>renw start render
W VTK : Warning: In vtkEGLRenderWindow.cxx, line 375
W VTK : vtkEGLRenderWindow (0xb400007622680900): Setting an EGL display to device index: -1 require EGL_EXT_device_base EGL_EXT_platform_device EGL_EXT_platform_base extensions
06-26 17:35:21.669 15585 7818 W VTK :
W VTK : Warning: In vtkEGLRenderWindow.cxx, line 377
W VTK : vtkEGLRenderWindow (0xb400007622680900): Attempting to use EGL_DEFAULT_DISPLAY...
06-26 17:35:21.669 15585 7818 W VTK :
F libc : Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x98 in tid 7818 (qtMainLoopThrea), pid 15585 (le.appVTKreldeb)
D ContentCatcher_injector: Interceptor : notifyActivityPause: org.qtproject.example.appVTKreldeb@org.qtproject.qt.android.bindings.QtActivity@113508424
D ContentCatcher_catcher: CatcherHolder : mCatcherList size: 0
I also tried the NativeVTK example, but the prompt app_dummy is undefined.Android Samples with latest ndk update fails due to deprecated app_dummy().I know that it is very difficult to combine qt and vtk, please let me know if there is a solution and I will also upload my progress at the same time.
Judging by this message:
It seems to me that the rendering backend (normally part of the graphics hardware driver) in the whatever device you’re using lacks the mentioned extensions.
Edit: VTK then falls back to using EGL_DEFAULT_DISPLAY
and the crash ensues.
Hello,I tracked the code and the issue is from Rendering/OpenGL2/vtkEGLRenderWindow.cxx
#if defined(__ANDROID__) || defined(ANDROID)
EGLint format = 0;
/* EGL_NATIVE_VISUAL_ID is an attribute of the EGLConfig that is
* guaranteed to be accepted by ANativeWindow_setBuffersGeometry().
* As soon as we picked a EGLConfig, we can safely reconfigure the
* ANativeWindow buffers to match, using EGL_NATIVE_VISUAL_ID. */
eglGetConfigAttrib(impl->Display, config, EGL_NATIVE_VISUAL_ID, &format);
ANativeWindow_setBuffersGeometry(impl->Window, 0, 0, format);
#endif
ANativeWindow_setBuffersGeometry produced a segmentation fault and impl->Window is nullptr.
I think it may be the reason for using qt android directly, but I don’t know how to modify it.
Hi,
Good job. Well, perhaps there’s a bit of defensive code or sanity check in there. I suggest reporting that issue here: https://gitlab.kitware.com/groups/vtk/-/issues .
My two cents: if impl->Window
is nullptr
, then it’s likely there is a prior call that instantiates the object that impl->Window
is supposed to point to. I don’t have experience in Android and Qt Quick, but I’d look at the part of the code where you setup your GUI and make Qt Quick and VTK start talking to each other. In normal Qt for desktop, we instantiate a QVTKOpenGLWindow
before doing anything else related to rendering in VTK.
best,
PC
Hi, I’m doing the same thing. I copy QQuickVTKItem class and related files in GUISupport/QtQuick dir in vtk sources into my project, after a little modification, I’m able to run some example. geometry rendering is ok, but volume rendering generate an error and display nothing. here is my example project, hope can help you. dunankai/vtk_qt_android: porting vtk to android qt (github.com)
I tried to do the same thing as you, but failed. Your project has helped me a lot. Thank you very much.
Louis Geombert’s merge request solve the volume rendering failure.Draft: Fix Volume rendering for WebAssembly (!11313) · 合并请求 · VTK / VTK · GitLab (kitware.com)
FYI @Louis_Gombert
this MR should fix Volume Rendering for VTK with GLES indeed, should it be WASM or mobile platforms.
Thank you all for your help, this is my project, I modified the Android interactor according to the existing interactor-style. By double-clicking to switch to one-finger operation mode, you can pan or rotate the actor when you slide your finger, and two-finger operation to scale the actor.
https://github.com/blueebrain/VTKAndroid