Skip to content

Building for Android fails with undefined symbol: qt_resourceFeatureZstd #1251

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
gambhiro opened this issue Apr 6, 2025 · 1 comment
Open

Comments

@gambhiro
Copy link

gambhiro commented Apr 6, 2025

I tried to build a small project based on the qml_minimal example for Android.

It was eventually successful. Some issues were configuration specific, but the Zstd issue relates to how the RCC command is composed in crates/qt-build-utils/src/lib.rs.

I installed Qt with the open source online installer to ~/Qt/.

Then installed the Rust targets (x86_64 is for the emulator such as Genymotion):

rustup target add aarch64-linux-android
rustup target add x86_64-linux-android

Cargo should use the correct qmake to find the correct Qt include folders:

In CMakeLists.txt:

if (ANDROID)
    set(qmake_path "$ENV{HOME}/Qt/6.8.3/android_x86_64/bin/qmake6")
endif()

cxx_qt_import_crate(
    MANIFEST_PATH rust/Cargo.toml 
    CRATES simsapa_lib
    LOCKED
    QMAKE ${qmake_path}

    QT_MODULES ...
)

I encountered the following errors:

Error: Missing Qt6QmlImportScanner_DIR

Qt is set to be not found because Qt6QmlImportScanner is not found in the Qt/6.8.3/android_ folders.

In Qt Creator, open Projects > Android Build > Current configuration

Add a Directory entry to the Initial Values tab, so that it will be saved to CMakeLists.txt.user

(TODO: How can this be set in CMakeLists.txt?)

Qt6QmlImportScanner_DIR
/home/<your-username>/Qt/6.8.3/gcc_64/lib/cmake/Qt6QmlImportScanner

Error: undefined symbol: qt_resourceFeatureZstd

ld.lld: error: undefined symbol: qt_resourceFeatureZstd
>>> referenced by qml_module_resources_com_profound_labs_simsapa.qrc.cpp:401 (/home/gambhiro/prods/apps/simsapa-project/simsapa-cxx-qt/simsapa/build/Android_Qt_6_8_2_Clang_x86_64-Debug/./cargo/build/x86_64-linux-android/debug/build/simsapa_lib-044fbcbd79e4a67a/out/qt-build-utils/qrc/qml_module_resources_com_profound_labs_simsapa.qrc.cpp:401)
>>>               699aa1b37edc0ef0-qml_module_resources_com_profound_labs_simsapa.qrc.o:(qResourceFeatureZstd())

Zstd compression has to be disabled for the RCC command to produce .qrc.cpp files which can compile for Android.

The CMAKE_AUTORCC_OPTIONS variable was not picked by CXX-Qt from CMakeLists.txt, e.g. this didn't work:

list(APPEND CMAKE_AUTORCC_OPTIONS "--no-zstd")

So I added the options directly in ‎crates/qt-build-utils/src/lib.rs

"--no-zstd",
"--format-version",
"1",
"--compress-algo",
"zlib",

As seen in this commit

let cmd = Command::new(self.rcc_executable.as_ref().unwrap())
    .args([
        input_path.to_str().unwrap(),
        "-o",
        output_path.to_str().unwrap(),
        "--name",
        &name,
        "--no-zstd",
        "--format-version",
        "1",
        "--compress-algo",
        "zlib",
    ])

Error: Not building the APK

(Related: #549)

The current qml_minimal example has in CMakeLists.txt:

add_executable(example_qml_minimal cpp/main.cpp)

Use qt_add_executable(), instead of add_executable(). Otherwise, Qt doesn't know what to package as the "application".

After this the app compiled successfully both for the emulator (x86_64) and the Android phone (aarch64).

@gambhiro gambhiro changed the title Building on Android fails with undefined symbol: qt_resourceFeatureZstd Building for Android fails with undefined symbol: qt_resourceFeatureZstd Apr 6, 2025
@LeonMatthesKDAB LeonMatthesKDAB moved this from Todo to ToDo - 0.8 in Cxx-Qt 1.0 Apr 16, 2025
@LeonMatthesKDAB
Copy link
Collaborator

@gambhiro Thank you for investigating this.

This seems like something we can improve by forwarding the options from CMake to our build system, and by allowing you to provide flags to RCC yourself.
I'll note it down for our general build system improvements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ToDo - 0.8
Development

No branches or pull requests

2 participants