Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Language Bindings
  4. Cross compilation C++ Linux -> Windows with Qt5
QtWS25 Last Chance

Cross compilation C++ Linux -> Windows with Qt5

Scheduled Pinned Locked Moved Unsolved Language Bindings
5 Posts 2 Posters 773 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    Golgotho
    wrote on 16 Mar 2023, 16:54 last edited by
    #1

    Hello, i am trying to do a cross compilation with MingW for Windows on Ubuntu.
    I got some problems on .ui compilation.

    Here is my qmake.pro :
    c76b824b-6a90-49e1-811a-fbc9b4834279-image.png

    I give you the code too:
    QMAKE_CXX = x86_64-w64-mingw32-g++
    QMAKE_LINK = x86_64-w64-mingw32-g++
    QMAKE_CXXFLAGS += -std=c++11 -m64 -Wfatal-errors
    QMAKE_LFLAGS += -static-libgcc -static-libstdc++
    MAKEFILE_GENERATOR = MINGW
    TARGET_PLATFORM = windows

    QT += gui core widgets

    HEADER_DIRS += $$system(find . -type d -name "Export")
    $$system(find . -type d -name "Sources")
    $$system(find . -type d -name "SharedPCH")

    for(dir, HEADER_DIRS) {
    INCLUDEPATH += $$dir
    }

    CONFIG += relative_paths
    OBJECTS_DIR = .obj
    UI_DIR = .ui
    MOC_DIR = .moc

    FORMS += $$system(find 01_IHM_CARPATHEV5 -name "*.ui")

    UI_HEADERS = $(FORMS:%.ui=%.h)

    HEADERS += $$system(find 01_IHM_CARPATHEV5 -name ".h")
    $$system(find 01_IHM_CARPATHEV5 -name "
    .hpp")

    SOURCES += $$system(find 01_IHM_CARPATHEV5 -name ".cpp")
    $$system(find 01_IHM_CARPATHEV5 -name "
    .c")

    TARGET = 01_IHM_CARPATHEV5
    TEMPLATE = app

    LIBS += -lQt5Gui
    -lws2_32
    -lQt5Widgets
    -lQt5Core

    QMAKE_CXXFLAGS_RELEASE += -O2
    QMAKE_CXXFLAGS_DEBUG += -g

    linux {
    DEFINES += NO_WINDOWS_H
    }

    DEFINES += Linux

    In my .moc directory, i got all my moc.cpp. In my .ui directory, i also have all my ui.h. But my .obj is empty and a got this error : e5c6c766-a81c-4051-b1ec-67df6c7f6caa-image.png
    I have no idea how to fix it. If you have any advices/tips/idea, it would be incredible.
    Thanks in advance.

    S 1 Reply Last reply 16 Mar 2023, 19:27
    0
    • G Golgotho
      16 Mar 2023, 16:54

      Hello, i am trying to do a cross compilation with MingW for Windows on Ubuntu.
      I got some problems on .ui compilation.

      Here is my qmake.pro :
      c76b824b-6a90-49e1-811a-fbc9b4834279-image.png

      I give you the code too:
      QMAKE_CXX = x86_64-w64-mingw32-g++
      QMAKE_LINK = x86_64-w64-mingw32-g++
      QMAKE_CXXFLAGS += -std=c++11 -m64 -Wfatal-errors
      QMAKE_LFLAGS += -static-libgcc -static-libstdc++
      MAKEFILE_GENERATOR = MINGW
      TARGET_PLATFORM = windows

      QT += gui core widgets

      HEADER_DIRS += $$system(find . -type d -name "Export")
      $$system(find . -type d -name "Sources")
      $$system(find . -type d -name "SharedPCH")

      for(dir, HEADER_DIRS) {
      INCLUDEPATH += $$dir
      }

      CONFIG += relative_paths
      OBJECTS_DIR = .obj
      UI_DIR = .ui
      MOC_DIR = .moc

      FORMS += $$system(find 01_IHM_CARPATHEV5 -name "*.ui")

      UI_HEADERS = $(FORMS:%.ui=%.h)

      HEADERS += $$system(find 01_IHM_CARPATHEV5 -name ".h")
      $$system(find 01_IHM_CARPATHEV5 -name "
      .hpp")

      SOURCES += $$system(find 01_IHM_CARPATHEV5 -name ".cpp")
      $$system(find 01_IHM_CARPATHEV5 -name "
      .c")

      TARGET = 01_IHM_CARPATHEV5
      TEMPLATE = app

      LIBS += -lQt5Gui
      -lws2_32
      -lQt5Widgets
      -lQt5Core

      QMAKE_CXXFLAGS_RELEASE += -O2
      QMAKE_CXXFLAGS_DEBUG += -g

      linux {
      DEFINES += NO_WINDOWS_H
      }

      DEFINES += Linux

      In my .moc directory, i got all my moc.cpp. In my .ui directory, i also have all my ui.h. But my .obj is empty and a got this error : e5c6c766-a81c-4051-b1ec-67df6c7f6caa-image.png
      I have no idea how to fix it. If you have any advices/tips/idea, it would be incredible.
      Thanks in advance.

      S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 16 Mar 2023, 19:27 last edited by
      #2

      Hi and welcome to devnet,

      One thing: start smaller. You seem to have a pretty heavy application to build and are doing some strange things in your .pro file. For example, linking explicitly the Qt libraries in the .pro file is wrong as it should already be done for you through the ˋQT` keyword.

      Create a simple default widget application.

      As for setting up cross-compilation, you should rather create a new mkspec if none already exists to setup your build. It's not the role of the project .pro file.

      You should also avoid setting the various XXX_DIR, it was mainly useful when build were done in the sources but this is something that should not be done anymore and out of source builds should be the default.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      G 1 Reply Last reply 17 Mar 2023, 08:35
      1
      • S SGaist
        16 Mar 2023, 19:27

        Hi and welcome to devnet,

        One thing: start smaller. You seem to have a pretty heavy application to build and are doing some strange things in your .pro file. For example, linking explicitly the Qt libraries in the .pro file is wrong as it should already be done for you through the ˋQT` keyword.

        Create a simple default widget application.

        As for setting up cross-compilation, you should rather create a new mkspec if none already exists to setup your build. It's not the role of the project .pro file.

        You should also avoid setting the various XXX_DIR, it was mainly useful when build were done in the sources but this is something that should not be done anymore and out of source builds should be the default.

        G Offline
        G Offline
        Golgotho
        wrote on 17 Mar 2023, 08:35 last edited by
        #3

        @SGaist said in Cross compilation C++ Linux -> Windows with Qt5:

        Create a simple default widget application

        Tanks for your answer, but im doing this cross compilation on docker container and i don't know if i can use QTCreator for build a widget application. You say that im doing strange things in my .pro, do you have some advices for fix that and idea of useless things i can delete ?

        G 1 Reply Last reply 17 Mar 2023, 10:34
        0
        • G Golgotho
          17 Mar 2023, 08:35

          @SGaist said in Cross compilation C++ Linux -> Windows with Qt5:

          Create a simple default widget application

          Tanks for your answer, but im doing this cross compilation on docker container and i don't know if i can use QTCreator for build a widget application. You say that im doing strange things in my .pro, do you have some advices for fix that and idea of useless things i can delete ?

          G Offline
          G Offline
          Golgotho
          wrote on 17 Mar 2023, 10:34 last edited by
          #4

          @Golgotho I have done the .mkspec and its working !! Still one more error but thanks !

          S 1 Reply Last reply 17 Mar 2023, 19:45
          0
          • G Golgotho
            17 Mar 2023, 10:34

            @Golgotho I have done the .mkspec and its working !! Still one more error but thanks !

            S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 17 Mar 2023, 19:45 last edited by
            #5

            @Golgotho what is the error left ?

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0

            2/5

            16 Mar 2023, 19:27

            • Login

            • Login or register to search.
            2 out of 5
            • First post
              2/5
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved