Python3-pyqt5_5.15.10.bb:do_compile failed

Hi folks,

i am building the yocto branch 7.3.0 and i am facing compilation error with recipe python3-pyqt5_5.15.10 as follows:

o moc_pluginloader.o moc_pluginloader.cpp
| In file included from ../../recipe-sysroot-native/usr/include/python3.12/Python.h:38,
| from ../../PyQt5-5.15.10/qmlscene/pluginloader.h:27,
| from moc_pluginloader.cpp:10:
| ../../recipe-sysroot-native/usr/include/python3.12/pyport.h:586:2: error: error “LONG_BIT definition appears wrong for platform (bad gcc/glibc config?).”
| 586 | error “LONG_BIT definition appears wrong for platform (bad gcc/glibc config?).”
| | ^~~~~
| ../../PyQt5-5.15.10/qmlscene/pluginloader.cpp: In member function ‘virtual void PyQt5QmlPlugin::registerTypes(const char*)’:
| ../../PyQt5-5.15.10/qmlscene/pluginloader.cpp:176:82: warning: ‘QString::SkipEmptyParts’ is deprecated [-Wdeprecated-declarations]
| 176 | QStringList env_dirs = QString::fromLatin1(env_path).split(sep, QString::SkipEmptyParts);
| | ^~~~~~~~~~~~~~
| In file included from ../../recipe-sysroot/usr/include/QtCore/qcoreapplication.h:44,
| from ../../recipe-sysroot/usr/include/QtCore/QCoreApplication:1,
| from ../../PyQt5-5.15.10/qmlscene/pluginloader.cpp:28:
| /home/build/yocto_build/build/tmp/work/armv7at2hf-neon-imx-tdx-linux-gnueabi/python3-pyqt5/5.15.10/recipe-sysroot/usr/include/QtCore/qstring.h:602:9: note: declared here
| 602 | SkipEmptyParts Q_DECL_ENUMERATOR_DEPRECATED
| | ^~~~~~~~~~~~~~
| ../../PyQt5-5.15.10/qmlscene/pluginloader.cpp:176:82: warning: ‘QString::SkipEmptyParts’ is deprecated [-Wdeprecated-declarations]
| 176 | QStringList env_dirs = QString::fromLatin1(env_path).split(sep, QString::SkipEmptyParts);
| | ^~~~~~~~~~~~~~
| /home/build/yocto_build/build/tmp/work/armv7at2hf-neon-imx-tdx-linux-gnueabi/python3-pyqt5/5.15.10/recipe-sysroot/usr/include/QtCore/qstring.h:602:9: note: declared here
| 602 | SkipEmptyParts Q_DECL_ENUMERATOR_DEPRECATED
| | ^~~~~~~~~~~~~~
| ../../PyQt5-5.15.10/qmlscene/pluginloader.cpp:176:67: warning: ‘QStringList QString::split(QChar, SplitBehavior, Qt::CaseSensitivity) const’ is deprecated: Use split(QChar sep, Qt::SplitBehavior …) variant instead [-Wdeprecated-declarations]
| 176 | QStringList env_dirs = QString::fromLatin1(env_path).split(sep, QString::SkipEmptyParts);
| | ~~~^~
| /home/build/yocto_build/build/tmp/work/armv7at2hf-neon-imx-tdx-linux-gnueabi/python3-pyqt5/5.15.10/recipe-sysroot/usr/include/QtCore/qstring.h:612:17: note: declared here
| 612 | QStringList split(QChar sep, SplitBehavior behavior,
| | ^

| make[1]: *** [Makefile:680: pluginloader.o] Error 1
| make[1]: *** Waiting for unfinished jobs…
| make[1]: *** [Makefile:683: moc_pluginloader.o] Error 1
| make[1]: Leaving directory ‘/home/build/yocto_build/build/tmp/work/armv7at2hf-neon-imx-tdx-linux-gnueabi/python3-pyqt5/5.15.10/build/qmlscene’
| make: *** [Makefile:58: sub-qmlscene-make_first-ordered] Error 2
| ERROR: oe_runmake failed
| WARNING: exit code 1 from a shell command.
ERROR: Task (/home/build/yocto_build/build/../layers/meta-qt5/recipes-python/pyqt5/python3-pyqt5_5.15.10.bb:do_compile) failed with exit code ‘1’
NOTE: Tasks Summary: Attempted 4105 tasks of which 0 didn’t need to be rerun and 1 failed.
NOTE: Writing buildhistory
NOTE: Writing buildhistory took: 5 seconds

Summary: 1 task failed:
/home/build/yocto_build/build/../layers/meta-qt5/recipes-python/pyqt5/python3-pyqt5_5.15.10.bb:do_compile
log: /home/build/yocto_build/build/tmp/work/armv7at2hf-neon-imx-tdx-linux-gnueabi/python3-pyqt5/5.15.10/temp/log.do_compile.2052312
Summary: There were 2 WARNING messages.
Summary: There were 2 ERROR messages, returning a non-zero exit code.

Thank you

Hi, I’m the Toradex AI Assistant.

I might make mistakes. Our support team will step in if needed. If I answered your question, please tick the “Solution” checkbox. For follow-up questions to me, please use @ToradexAI in your post.

Did you like my answer? :+1: :-1:


Hello! Thank you for providing the detailed log and context for your build error.

You are encountering a compilation failure with the python3-pyqt5_5.15.10 recipe on Yocto branch 7.3.0, specifically this critical error:

error: “LONG_BIT definition appears wrong for platform (bad gcc/glibc config?).”

Analysis & Guidance

This error is rooted in a mismatch between the Python 3.12 build, your target architecture (likely ARM 32-bit based on armv7at2hf-neon), and the build system’s detection of the LONG_BIT macro. LONG_BIT should be 32 for 32-bit targets, but if it’s wrong, the build fails as Python’s pyport.h intentionally aborts compilation to prevent potential ABI issues.

Common causes for this error:

  1. Inconsistent/Incorrect Toolchain: If your toolchain or glibc is not configured correctly for your target architecture, the build will break.
  2. Mixing Host and Target Headers: Sometimes, Yocto recipes may mistakenly use host (x86_64) headers/tools instead of the target (ARM) versions.
  3. Unsupported Python or PyQt5 Version: Python 3.12 is relatively new for embedded architectures, and not all Yocto layers are fully ready for it in every recipe.

Possible Solutions

  1. Check Yocto Branch and Layers

    • Ensure you are using compatible branches for all your layers, especially meta-qt5 and meta-python. Mixing branches across Yocto versions (e.g. mixing kirkstone with langdale) can cause these definitions to break.
  2. Try Adding Python to Image Properly
    For Python 3, ensure the build includes Python by following:

    IMAGE_INSTALL_append = " python"
    

    (Python in Linux with Yocto)

  3. Check Toolchain Configuration

    • Inspect your local.conf and build/conf files for any explicit toolchain or architecture settings that might cause conflicting configurations.
    • Clean your build (for this recipe and dependencies) to make sure no stale files are causing issues:
      bitbake -c clean python3-pyqt5
      bitbake -c cleansstate python3-pyqt5
      
  4. Qt5/PyQt5 Compatibility

    • The Qt5 on iMX8 development blog gives guidance but doesn’t address PyQt5 build errors directly.
    • Consider downgrading to a more stable/older Python version if this project permits, or using a slightly older meta-qt5 layer or Yocto branch if possible.
  5. Check for Known Issues

Warnings about Deprecated Qt APIs

The warnings regarding deprecated Qt API usage (e.g. QString::SkipEmptyParts) are expected with newer Qt versions but should not cause the build to fail.

Summary

  • Verify that all your Yocto layers are from compatible branches for 7.3.0.
  • Double check that your toolchain is not mismatched for your target.
  • Clean and rebuild python3-pyqt5 after making any changes.
  • Consider switching to Python 3.10 or 3.11 if Python 3.12 introduces incompatibilities and your project allows.

If the issue persists, try to reproduce the error with a minimal set of layers and a default toolchain to confirm if it’s a meta-qt5 or Python 3.12 compatibility issue.

Best regards,
Toradex AI Assistant.

Hello @farooq,

Was the ToradexAI able to answer your question and bring you to a solution?

Best regards,
Collin

Hello collin,

Not really. i added a bbappend file as bellow:

Fix for:

LONG_BIT definition appears wrong for platform (bad gcc/glibc config?)

and “file format not recognized” linking errors

Cause:

sip-build detects host Python headers/libs instead of target sysroot ones

do_configure:prepend() {
cd ${S}

# Force sip to use target Python include dir
grep -q '\[tool.sip.project\]' pyproject.toml || echo "[tool.sip.project]" >> pyproject.toml
sed -i -e '/py-include-dir/d' pyproject.toml
sed -i -e "/\[tool\.sip\.project\]/a py-include-dir = \"${STAGING_INCDIR}/${PYTHON_DIR}${PYTHON_ABI}\"" pyproject.toml

# Force sip to link against target Qt libraries
grep -q '\[tool.sip.bindings.PyQt5\]' pyproject.toml || echo "[tool.sip.bindings.PyQt5]" >> pyproject.toml
sed -i -e '/library-dirs/d' pyproject.toml
sed -i -e "/\[tool\.sip\.bindings\.PyQt5\]/a library-dirs = [\"${STAGING_LIBDIR}\"]" pyproject.toml

}

do_compile:prepend() {
# fix .pro defining LIBS with recipe-sysroot-native hence generating the error:
# file not recognized: file format not recognized
find ${B} -name "
.pro" -type f -exec sed -i -E ‘s,^(LIBS)[[:blank:]]++=[[:blank:]]+(.)/recipe-sysroot-native/(.)$,\1 += \2/recipe-sysroot/\3,’ {} ;
}

It worked for me. Thanks.