Bug 405661 - Cross-mingw64 compilation: Cannot compile app using syntax highlighting framework
Summary: Cross-mingw64 compilation: Cannot compile app using syntax highlighting frame...
Status: RESOLVED NOT A BUG
Alias: None
Product: frameworks-syntax-highlighting
Classification: Frameworks and Libraries
Component: framework (show other bugs)
Version: 5.56.0
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-03-19 19:59 UTC by Martin Höher
Modified: 2019-07-13 22:05 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Höher 2019-03-19 19:59:12 UTC
SUMMARY

In a Fedora mingw64 cross compile environment for Windows, in an app using the syntax highlighting framework, compilation fails with the following error:

In file included from /usr/i686-w64-mingw32/sys-root/mingw/include/c++/ext/string_conversions.h:41,
                 from /usr/i686-w64-mingw32/sys-root/mingw/include/c++/bits/basic_string.h:6400,
                 from /usr/i686-w64-mingw32/sys-root/mingw/include/c++/string:52,
                 from /usr/i686-w64-mingw32/sys-root/mingw/include/c++/stdexcept:39,
                 from /usr/i686-w64-mingw32/sys-root/mingw/include/c++/array:39,
                 from /usr/i686-w64-mingw32/sys-root/mingw/include/c++/tuple:39,
                 from /usr/i686-w64-mingw32/sys-root/mingw/include/c++/functional:54,
                 from ../lib/datamodel/library.h:4,
                 from ../lib/application.h:4,
                 from ../lib/application.cpp:1:
/usr/i686-w64-mingw32/sys-root/mingw/include/c++/cstdlib:75:15: fatal error: stdlib.h: No such file or directory
 #include_next <stdlib.h>
               ^~~~~~~~~~



STEPS TO REPRODUCE
1. Set up mingw64 cross compile environment in Fedora by installing from repository.
2. Install ECM and syntax-highlighting framework from source.
3. Try to compile an app which uses cmake and which compiles and links against the syntax highlighting library.

OBSERVED RESULT

Compilation fails (e.g. when #include <functional> is used).

EXPECTED RESULT

Compilation works fine.


SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 5.56.0
Qt Version: 5.11.3

ADDITIONAL INFORMATION


I am developing an app which I also want to compile for Windows. For this purpose, I am using the mingw64 packages provided by Fedora. Qt 5 is provided as part of these packages as well. I am using Docker for this. To reproduce, you can create a Docker image using the following Dockerfile:

=====================================
FROM fedora

RUN \
\
    dnf install -y --nogpgcheck \
        cmake \
        make \
        ninja-build \
        python3 \
        python \
        git \
        wget \
        \
        qt5-qtxmlpatterns-devel \
        qt5-linguist \
        appstream \
        \
        mingw32-qt5-qmake \
        mingw32-qt5-qmldevtools \
        mingw32-qt5-qmldevtools-devel \
        mingw32-qt5-qt3d \
        mingw32-qt5-qt3d-tools \
        mingw32-qt5-qtactiveqt \
        mingw32-qt5-qtbase \
        mingw32-qt5-qtbase-devel \
        mingw32-qt5-qtcharts \
        mingw32-qt5-qtdeclarative \
        mingw32-qt5-qtgraphicaleffects \
        mingw32-qt5-qtimageformats \
        mingw32-qt5-qtlocation \
        mingw32-qt5-qtmultimedia \
        mingw32-qt5-qtquickcontrols \
        mingw32-qt5-qtsensors \
        mingw32-qt5-qtserialport \
        mingw32-qt5-qtsvg \
        mingw32-qt5-qttools \
        mingw32-qt5-qttools-tools \
        mingw32-qt5-qttranslations \
        mingw32-qt5-qtwebkit \
        mingw32-qt5-qtwebsockets \
        mingw32-qt5-qtwinextras \
        mingw32-qt5-qtxmlpatterns \
        mingw32-nsis \
        mingw32-nsiswrapper \
        \
        && \
        cd / && \
        git clone https://github.com/qt/qtquickcontrols2.git && \
        cd qtquickcontrols2 && \
        git checkout v$(mingw32-qmake-qt5 -query QT_VERSION) && \
        mingw32-qmake-qt5 && \
        make -j4 && \
        make install && \
        cd .. && \
        rm -rf qtquickcontrols2
=====================================

In my app, I also want to use the syntax highlighting framework. As this library is not part of the mingw packages included in Fedora, I compile and install both ECM and the syntax highlighting framework as part of my build script:


    # Install ECM
    pushd 3rdparty/KDE/extra-cmake-modules
    mkdir -p build
    cd build
    mingw32-cmake -GNinja ..
    cmake --build .
    cmake --build . --target install
    popd

    # Install KDE syntax highlighting
    pushd 3rdparty/KDE/syntax-highlighting
    mkdir -p build
    cd build
    mingw32-cmake -GNinja -DKF5_HOST_TOOLING=/usr ..
    cmake --build .
    cmake --build . --target install
    popd

After this is done, I try to compile my own app, which, among other things, does the following to include the syntax highlighting library:

# Find KDE Syntax Highlighting engine
find_package(KF5SyntaxHighlighting)
if(KF5SyntaxHighlighting_FOUND)
    set(LIB_LIBRARIES ${LIB_LIBRARIES} KF5::SyntaxHighlighting)
    set(LIB_DEFINES ${LIB_DEFINES} HAVE_KF5_SYNTAX_HIGHLIGHTING)
endif()

The two variables LIB_LIBRARIES and LIB_DEFINES are used later on to set linker and compiler flags for the app. When trying to build, however, the compilation fails e.g. when using

    #include <functional>

When I edit the file /usr/i686-w64-mingw32/sys-root/mingw/lib/cmake/KF5SyntaxHighlighting/KF5SyntaxHighlightingTargets.cmake and change the following:

    set_target_properties(KF5::SyntaxHighlighting PROPERTIES
      INTERFACE_INCLUDE_DIRECTORIES "/usr/i686-w64-mingw32/sys-root/mingw/include/KF5/KSyntaxHighlighting;/usr/i686-w64-mingw32/sys-root/mingw/include/KF5;/usr/i686-w64-mingw32/sys-root/mingw/include"
      INTERFACE_LINK_LIBRARIES "Qt5::Gui"
    )

to:

    set_target_properties(KF5::SyntaxHighlighting PROPERTIES
      INTERFACE_INCLUDE_DIRECTORIES "/usr/i686-w64-mingw32/sys-root/mingw/include/KF5/KSyntaxHighlighting;/usr/i686-w64-mingw32/sys-root/mingw/include/KF5"
      INTERFACE_LINK_LIBRARIES "Qt5::Gui"
    )

Then compilation works fine. I am not entirely sure, but it seems that this might be due to the include directories set there are passed to consuming targets via the `-isystem` switch.
Comment 1 Christoph Cullmann 2019-07-13 22:05:29 UTC
This is no issue of this framework, but your cross compilation setup, sorry.
If system headers don't find their implementations, we can't do a thing.
It might work for other frameworks if they don't use these headers.