Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. German
  4. cmake Problem unter Windows
Forum Updated to NodeBB v4.3 + New Features

cmake Problem unter Windows

Scheduled Pinned Locked Moved Solved German
5 Posts 2 Posters 702 Views 1 Watching
  • 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.
  • M Offline
    M Offline
    msauer75
    wrote on last edited by
    #1

    Hallo zusammen,

    nachdem ich unter linux mein Qt/QML Projekt erfolgreich auf cmake umgestellt habe wollte ich das selbe Projekt für Windows compilieren. Allerdings schlägt diese jeder Menge Fehlermeldungen fehl:

    [1/68 0.2/sec] Building CXX object lib-datad/CMakeFiles/datad.dir/source/float-decorator.cpp.obj
    ../lib-datad/source/float-decorator.cpp:24:1: warning: 'lib::datad::FloatDecorator::FloatDecorator(QObject*, const QString&, const QString&, float)' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
     FloatDecorator::FloatDecorator(QObject* _Parent, const QString& _Key, const QString& _Label, float _Value)
     ^~~~~~~~~~~~~~
    ../lib-datad/source/float-decorator.cpp:30:1: warning: 'virtual lib::datad::FloatDecorator::~FloatDecorator()' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
     FloatDecorator::~FloatDecorator()
     ^~~~~~~~~~~~~~
    

    und

    [1/57 4.6/sec] Linking CXX shared library lib-db\libdb.dll
    FAILED: lib-db/libdb.dll lib-db/libdb.dll.a 
    cmd.exe /C "cd . && D:\Programme\Qt\Tools\mingw810_64\bin\g++.exe -Wall -W -D_REENTRANT -fPIC -O3 -DNDEBUG   -shared -o lib-db\libdb.dll -Wl,--out-implib,lib-db\libdb.dll.a -Wl,--major-image-version,0,--minor-image-version,0 lib-db/CMakeFiles/db.dir/db_autogen/mocs_compilation.cpp.obj lib-db/CMakeFiles/db.dir/source/database.cpp.obj  D:/Programme/Qt/5.15.1/mingw81_64/lib/libQt5Sql.a  D:/Programme/Qt/5.15.1/mingw81_64/lib/libQt5Core.a  -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ."
    lib-db/CMakeFiles/db.dir/db_autogen/mocs_compilation.cpp.obj:mocs_compilation.cpp:(.text+0xb): undefined reference to `__imp__ZN3lib2db8Database16staticMetaObjectE'
    lib-db/CMakeFiles/db.dir/db_autogen/mocs_compilation.cpp.obj:mocs_compilation.cpp:(.text+0xa5): undefined reference to `__imp__ZN3lib2db8Database16staticMetaObjectE'
    lib-db/CMakeFiles/db.dir/db_autogen/mocs_compilation.cpp.obj:mocs_compilation.cpp:(.text+0x175): undefined reference to `__imp__ZN3lib2db8Database16staticMetaObjectE'
    lib-db/CMakeFiles/db.dir/db_autogen/mocs_compilation.cpp.obj:mocs_compilation.cpp:(.text.startup+0x3): undefined reference to `__imp__ZN3lib2db8Database16staticMetaObjectE'
    lib-db/CMakeFiles/db.dir/source/database.cpp.obj:database.cpp:(.text+0x119): undefined reference to `__imp__ZN3lib2db8Database7ErrorDbEh7QString'
    lib-db/CMakeFiles/db.dir/source/database.cpp.obj:database.cpp:(.text+0x588): undefined reference to `__imp__ZN3lib2db8Database7ErrorDbEh7QString'
    lib-db/CMakeFiles/db.dir/source/database.cpp.obj:database.cpp:(.text+0xbf3): undefined reference to `__imp__ZN3lib2db8Database7ErrorDbEh7QString'
    lib-db/CMakeFiles/db.dir/source/database.cpp.obj:database.cpp:(.text+0x11ce): undefined reference to `__imp__ZN3lib2db8Database7ErrorDbEh7QString'
    lib-db/CMakeFiles/db.dir/source/database.cpp.obj:database.cpp:(.text+0x1bb9): undefined reference to `__imp__ZN3lib2db8Database7ErrorDbEh7QString'
    lib-db/CMakeFiles/db.dir/source/database.cpp.obj:database.cpp:(.text+0x1f5b): more undefined references to `__imp__ZN3lib2db8Database7ErrorDbEh7QString' follow
    lib-db/CMakeFiles/db.dir/source/database.cpp.obj:database.cpp:(.text+0x70a3): undefined reference to `__imp__ZTVN3lib2db8DatabaseE'
    lib-db/CMakeFiles/db.dir/source/database.cpp.obj:database.cpp:(.text+0x71b9): undefined reference to `__imp__ZTVN3lib2db8DatabaseE'
    lib-db/CMakeFiles/db.dir/source/database.cpp.obj:database.cpp:(.text+0x72b9): undefined reference to `__imp__ZTVN3lib2db8DatabaseE'
    lib-db/CMakeFiles/db.dir/source/database.cpp.obj:database.cpp:(.text$_ZN3lib2db15DatabasePrivate8DoSearchEv[_ZN3lib2db15DatabasePrivate8DoSearchEv]+0x9bf): undefined reference to `__imp__ZN3lib2db8Database7ErrorDbEh7QString'
    lib-db/CMakeFiles/db.dir/source/database.cpp.obj:database.cpp:(.text$_ZN3lib2db15DatabasePrivate8DoSearchEv[_ZN3lib2db15DatabasePrivate8DoSearchEv]+0xd93): undefined reference to `__imp__ZN3lib2db8Database7ErrorDbEh7QString'
    lib-db/CMakeFiles/db.dir/source/database.cpp.obj:database.cpp:(.text$_ZN3lib2db15DatabasePrivate8DoSearchEv[_ZN3lib2db15DatabasePrivate8DoSearchEv]+0x1013): undefined reference to `__imp__ZN3lib2db8Database7ErrorDbEh7QString'
    lib-db/CMakeFiles/db.dir/source/database.cpp.obj:database.cpp:(.text$_ZN3lib2db15DatabasePrivate8DoSearchEv[_ZN3lib2db15DatabasePrivate8DoSearchEv]+0x1313): undefined reference to `__imp__ZN3lib2db8Database7ErrorDbEh7QString'
    lib-db/CMakeFiles/db.dir/source/database.cpp.obj:database.cpp:(.text$_ZN3lib2db15DatabasePrivate12GetRowSearchEv[_ZN3lib2db15DatabasePrivate12GetRowSearchEv]+0x326): undefined reference to `__imp__ZN3lib2db8Database7ErrorDbEh7QString'
    lib-db/CMakeFiles/db.dir/source/database.cpp.obj:database.cpp:(.text$_ZN3lib2db15DatabasePrivate12GetRowSearchEv[_ZN3lib2db15DatabasePrivate12GetRowSearchEv]+0x6b9): more undefined references to `__imp__ZN3lib2db8Database7ErrorDbEh7QString' follow
    collect2.exe: error: ld returned 1 exit status
    [2/57 0.9/sec] Building CXX object lib-jsonrpc/CMakeFiles/jsonrpc.dir/jsonrpc_autogen/mocs_compilation.cpp.obj
    ninja: build stopped: subcommand failed.
    09:28:56: Der Prozess "D:\Programme\Qt\Tools\CMake_64\bin\cmake.exe" wurde mit dem Rückgabewert 1 beendet.
    Fehler beim Erstellen/Deployment des Projekts gc-ui (Kit: Desktop Qt 5.15.1 MinGW 64-bit)
    Bei der Ausführung von Schritt "Erstellen"
    09:28:56: Verstrichene Zeit: 00:04.
    

    Hat einer eine Idee warum das Problem bei dem CMAKE Projekt existiert und mit QMAKE gibt es keine Fehler?

    Danke für Eure Hilfe.
    gruss
    martin

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #4

      Das hat nichts mit cmake zu tun. Ist die Klasse Database in der Lib die Du baust oder in einer externen?
      Aber eigentlich egal. Das exort-Macro ist falsch (dllexort/dllimport) und nur du kannst wissen wo und wie du es setzt da wir deinen Code nicht haben.

      Siehe https://doc.qt.io/qt-5/sharedlibrary.html

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      1
      • Christian EhrlicherC Offline
        Christian EhrlicherC Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #2

        Deine imort/export macros für die Library gegen die Du linkst ist falsch.

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        1 Reply Last reply
        0
        • M Offline
          M Offline
          msauer75
          wrote on last edited by
          #3

          Meine cmake sieht so aus:

          cmake_minimum_required(VERSION 3.10)
          
          set(LIB "datad")
          
          project(lib-${LIB} VERSION 1.0.0)
          
          set(CMAKE_CXX_STANDARD 11)
          set(CMAKE_CXX_STANDARD_REQUIRED ON)
          set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -W -D_REENTRANT -fPIC")
          set(CMAKE_AUTOMOC ON)
          set(CMAKE_AUTORCC ON)
          set(CMAKE_AUTOUIC ON)
          
          find_package(Qt5 COMPONENTS Core REQUIRED)
          find_package(Qt5 COMPONENTS Qml  REQUIRED)
          
          include_directories("source/")
          include_directories("source/helper")
          
          set(SOURCES
              source/data-decorator.cpp
              source/bool-decorator.cpp
              source/float-decorator.cpp
              source/int-decorator.cpp
              source/string-decorator.cpp
              source/enumerator-decorator.cpp
              source/koordinaten-decorator.cpp
              source/attribute-decorator.cpp
              source/dropdown.cpp
              source/helper/koordinaten.cpp
              source/helper/dropdown-value.cpp
              source/string_bool-decorator.cpp
          
              source/lib-datad_global.h
              source/data-decorator.h
              source/bool-decorator.h
              source/float-decorator.h
              source/int-decorator.h
              source/string-decorator.h
              source/enumerator-decorator.h
              source/koordinaten-decorator.h
              source/attribute-decorator.h
              source/dropdown.h
              source/helper/koordinaten.h
              source/helper/dropdown-value.h
              source/string_bool-decorator.h
          )
          
          add_library(${LIB} SHARED ${SOURCES})
          
          target_link_libraries(
              ${LIB} 
                  Qt5::Core
                  Qt5::Qml
              )
          

          An welcher Stelle muss ich denn für Windows etwas ändern?

          1 Reply Last reply
          0
          • Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #4

            Das hat nichts mit cmake zu tun. Ist die Klasse Database in der Lib die Du baust oder in einer externen?
            Aber eigentlich egal. Das exort-Macro ist falsch (dllexort/dllimport) und nur du kannst wissen wo und wie du es setzt da wir deinen Code nicht haben.

            Siehe https://doc.qt.io/qt-5/sharedlibrary.html

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            1 Reply Last reply
            1
            • M Offline
              M Offline
              msauer75
              wrote on last edited by
              #5

              Ok. Das wars.
              In meinen Libraries gab es ein Include-File, das diese Macros richtig gesetzt hat und in den alten qmake Projekt Dateien waren die entsprechenden Compiler Defines enthalten. Diese hab ich jetzt in das cmake übernommen und dann läuft es.

              Danke Dir für die Hilfe.
              gruss
              martin

              1 Reply Last reply
              0

              • Login

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