Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Linker issues only in QT Creator using MinGw64
Forum Updated to NodeBB v4.3 + New Features

Linker issues only in QT Creator using MinGw64

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
19 Posts 3 Posters 2.0k Views 2 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
    Mr. Calogero
    wrote on last edited by
    #1

    Hi there!

    Houston, I have a problem with my Linker.

    Things i did:

    I wrote a library for Windows in VS and compiled in the IDE, obtaining the .lib and .h files.
    Tested the library in a new project in VS (console application). The library works as expected.
    Copied the .lib and .h files in library/lib and library/include directories inside the QT proj.
    Imported the library in QTCreator using the import library tool.
    

    After these steps, the compiler reports no errors but the linker reports "undefined reference" for every symbol of the library i use in the main of the QTCreator app.

    My question is: why i cannot include and use a library in QTC while that library works perfectly on other IDEs? I will try on more environments and give updates here.

    Inside the library there's a single class declared in the .h and defined in the .cpp as usual.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      It's because you can't mix and match C++ libraries built with Visual Studio and MinGW.

      Also, Visual Studio started to have backward compatibility only since the 2017 release.

      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
      1
      • M Offline
        M Offline
        Mr. Calogero
        wrote on last edited by
        #3

        Hello and thank you.

        The problem is:
        I have to use some windows system calls that are compilable only by linking windows sdk, which is in .lib format.

        I was not able to build those calls using QTCreator and MinGw, so i thought i could build a library (which make use of those calls) in visual studio, and then export that library to QT Creator for being compiled with MinGW.

        So if you say there's no possibility to make mixes, i have no idea how to solve this problem than.

        Let me know if some sort of solution exists.

        jsulmJ 1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Which system calls do you need ?

          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
          • M Offline
            M Offline
            Mr. Calogero
            wrote on last edited by
            #5

            I need IPropertyStorageInterface sys calls, to manage COM object and modify/read file details like "Author" or "Tag" and others..
            I didn't find anyone who used those, the only one way to accomplish this was using those libraries, taken from Windows SDK installation, and using Visual Studio, because MinGw apparently doesn't like Windows libraries.

            1 Reply Last reply
            0
            • M Mr. Calogero

              Hello and thank you.

              The problem is:
              I have to use some windows system calls that are compilable only by linking windows sdk, which is in .lib format.

              I was not able to build those calls using QTCreator and MinGw, so i thought i could build a library (which make use of those calls) in visual studio, and then export that library to QT Creator for being compiled with MinGW.

              So if you say there's no possibility to make mixes, i have no idea how to solve this problem than.

              Let me know if some sort of solution exists.

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @Mr-Calogero said in Linker issues only in QT Creator using MinGw64:

              i have no idea how to solve this problem than.

              You can use MSVC++ compiler instead of MinFW (of course you have also to install MSVC++ Qt build).

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              M 1 Reply Last reply
              0
              • jsulmJ jsulm

                @Mr-Calogero said in Linker issues only in QT Creator using MinGw64:

                i have no idea how to solve this problem than.

                You can use MSVC++ compiler instead of MinFW (of course you have also to install MSVC++ Qt build).

                M Offline
                M Offline
                Mr. Calogero
                wrote on last edited by
                #7

                @jsulm Thank you, i managed to solve my problem.

                moral of the story: If you want to use windows apis which are part of the windows sdk and are inside a .lib file, you have to use MSVC.

                I recompiled my factotum library i developed for years in MSVC, and now i am able to compile softwares for windows and use my library at the same time, with the difference that now i can compile windows api .lib files with no problem (i'm not sure if mingw supports them, i read somewhere it only supports 32bit libraries, not sure if it's true).

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  MinGW supports both 32 and 64 bits.

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

                  M 1 Reply Last reply
                  0
                  • SGaistS SGaist

                    MinGW supports both 32 and 64 bits.

                    M Offline
                    M Offline
                    Mr. Calogero
                    wrote on last edited by
                    #9

                    @SGaist Btw, for some reason it cannot link some Microsoft libraries in .lib file

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      Are these static or dynamic librairies ?
                      If the later, did you properly export the symbols of your library ?

                      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
                      • M Offline
                        M Offline
                        Mr. Calogero
                        wrote on last edited by
                        #11

                        I tried both static and dynamic libraries.
                        I would rather dynamic ones. I have a library that i use in all my softwares and when i compile i can find the .dll file only. I take that and all the headers files and copy them to the project that uses this library, but it cannot resolve symbols because it requires an import library (.lib), so it compiles because it finds all the headers but it does not link and so it fails.

                        1 Reply Last reply
                        0
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #12

                          Then the important point: are you properly exporting you libraries symbol ?

                          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
                          • M Offline
                            M Offline
                            Mr. Calogero
                            wrote on last edited by Mr. Calogero
                            #13

                            What do you mean? With MinGw i used to simply compile and deploy the library. I setted up the IDE with install argument and all the install paths so it used to export in /dist all the header (copied) and the .a and .dll files, and it used to work like a charm. I don't know how to do it with MSVC neither where to find infos on how to do it. I'm just compiling and getting the .dll (or .lib if i configure for static library) and that's it...I'm probably forgetting something.

                            1 Reply Last reply
                            0
                            • SGaistS Offline
                              SGaistS Offline
                              SGaist
                              Lifetime Qt Champion
                              wrote on last edited by
                              #14

                              See the Creating Shared Library part in Qt's documentation.

                              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
                              1
                              • M Offline
                                M Offline
                                Mr. Calogero
                                wrote on last edited by
                                #15

                                I've never find such a page.. although i looked for it for a lot.
                                I managed to compile my library but it does not work on the client side. It's because i have some classes such:

                                class Q_DECL_EXPORT myClass : std::exception
                                {
                                //blablabla
                                }
                                

                                and so, it doesn't work because while there's not problem with "myClass", base class "exception" of C++ must be "exportable", and it's not.

                                How can i export in the dll exporting table a symbol of the C++ system libraries?

                                1 Reply Last reply
                                0
                                • SGaistS Offline
                                  SGaistS Offline
                                  SGaist
                                  Lifetime Qt Champion
                                  wrote on last edited by
                                  #16

                                  You did not follow the example correctly. You are not supposed to use the two Qt macros directly.

                                  Create your own that will use them both like shown in the documentation I linked.

                                  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
                                  • M Offline
                                    M Offline
                                    Mr. Calogero
                                    wrote on last edited by
                                    #17

                                    I did everything correctly. I created my own macro and used it, i wrote "Q_DECL_EXPORT" in the example to clarify. I don't even have a class called "myClass" for that matter.

                                    1 Reply Last reply
                                    0
                                    • SGaistS Offline
                                      SGaistS Offline
                                      SGaist
                                      Lifetime Qt Champion
                                      wrote on last edited by
                                      #18

                                      Symbol exportation does not apply only to classes.

                                      Can you show your actual code ?

                                      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
                                      • M Offline
                                        M Offline
                                        Mr. Calogero
                                        wrote on last edited by
                                        #19

                                        Thank you, i solved the problem! Now everything works fine, there was an unhandled exception in my code and i thought it was a link issue but it wasn't. The library builds and links with no problem now, thanks again!

                                        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