Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Link external library with MSCV compiler

Link external library with MSCV compiler

Scheduled Pinned Locked Moved Solved General and Desktop
qtcreator 5.11librarylinker errorsmsvcmingw
34 Posts 4 Posters 14.3k 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.
  • E elsa
    22 Aug 2018, 15:18

    @JonB the libraries have both the .dll and .lib files and according to the library's website they support MSVC (right?).

    J Offline
    J Offline
    JonB
    wrote on 22 Aug 2018, 15:20 last edited by JonB
    #6

    @elsa
    That page would imply it's all MSVC anyway there's no mention of MinGW?
    So change your Qt project to link against MSVC .lib files?

    E 1 Reply Last reply 22 Aug 2018, 15:28
    0
    • J JonB
      22 Aug 2018, 15:20

      @elsa
      That page would imply it's all MSVC anyway there's no mention of MinGW?
      So change your Qt project to link against MSVC .lib files?

      E Offline
      E Offline
      elsa
      wrote on 22 Aug 2018, 15:28 last edited by
      #7

      @JonB how do I do this? The code mentioned in my question was used for MinGW and doesn't work for MSCV, so how can I modify it? (I think these two lines link the .dll files, which are compatible with MinGW afaik, and for MSCV we need to explicitly tell it to choose the .lib files) You traditionally do not write the endings of the file name, so how can i specify it?
      (and sorry for not replying right away, I can only post every 600s -.-)

      J 1 Reply Last reply 22 Aug 2018, 15:36
      1
      • E elsa
        22 Aug 2018, 15:28

        @JonB how do I do this? The code mentioned in my question was used for MinGW and doesn't work for MSCV, so how can I modify it? (I think these two lines link the .dll files, which are compatible with MinGW afaik, and for MSCV we need to explicitly tell it to choose the .lib files) You traditionally do not write the endings of the file name, so how can i specify it?
        (and sorry for not replying right away, I can only post every 600s -.-)

        J Offline
        J Offline
        JonB
        wrote on 22 Aug 2018, 15:36 last edited by JonB
        #8

        @elsa
        I'm going to have to bow out, because I haven't used MinGW, I don't use Qt Creator/cmake/C++, someone else may know better than I.

        I will say, I'm confused, because if the libraries are from that page it only talks about MSVC, so I don't even know how MinGW came into it.

        I think you should:

        • Establish what/where your library files, and whether they are MSVC or MinGW.
        • Make sure however you configure your project to generate linker lines it's using the right linker and command-line options for whatever the correct files for it are. When you changed over from MinGW to MSVC you must have had to re-configure the makes from scratch I imagine, telling it which compiler/linker you're using, I imagine. I don't know, but those link library lines you show still look a bit gcc rather than msvc/link to me, but I could be mistaken.
        • Make sure your "unresolved"s are not because you are actually trying to call any functions which are not documented as exported from the third-party libraries.
        • Maybe find a couple of "typical" examples of the "unresolved external symbol errors" you are getting and show them here. It may give us an idea of just what sort of thing it's trying to find.
        E 1 Reply Last reply 23 Aug 2018, 07:12
        3
        • M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 22 Aug 2018, 18:19 last edited by
          #9

          Hi
          From page
          http://arma.sourceforge.net/download.html
          seems they used VS 2012.

          Did you compile a new version with the new visual studio ( i assume you didn't use 2012) and new VS cannot load old VS dlls.

          what version of VS did u use ?

          E 1 Reply Last reply 23 Aug 2018, 06:59
          2
          • J Offline
            J Offline
            JonB
            wrote on 22 Aug 2018, 19:00 last edited by JonB
            #10

            In https://forum.qt.io/topic/75458/compatibility-libraries-generated-by-msvc-and-mingw/3 @SGaist also wrote

            Thus if any of your dependencies needs a particular version of VS, you have to stay with it.

            @elsa Please do show some examples of the error messages.

            E 1 Reply Last reply 23 Aug 2018, 06:56
            0
            • J JonB
              22 Aug 2018, 19:00

              In https://forum.qt.io/topic/75458/compatibility-libraries-generated-by-msvc-and-mingw/3 @SGaist also wrote

              Thus if any of your dependencies needs a particular version of VS, you have to stay with it.

              @elsa Please do show some examples of the error messages.

              E Offline
              E Offline
              elsa
              wrote on 23 Aug 2018, 06:56 last edited by
              #11

              @JonB see my edit.

              J 1 Reply Last reply 23 Aug 2018, 07:01
              0
              • M mrjj
                22 Aug 2018, 18:19

                Hi
                From page
                http://arma.sourceforge.net/download.html
                seems they used VS 2012.

                Did you compile a new version with the new visual studio ( i assume you didn't use 2012) and new VS cannot load old VS dlls.

                what version of VS did u use ?

                E Offline
                E Offline
                elsa
                wrote on 23 Aug 2018, 06:59 last edited by
                #12

                @mrjj hi, I have VS17 and VS15 installed, but yeah, good point. Microsoft has a redistributable for VS12. I will try using it and update you.

                1 Reply Last reply
                0
                • E elsa
                  23 Aug 2018, 06:56

                  @JonB see my edit.

                  J Offline
                  J Offline
                  JonB
                  wrote on 23 Aug 2018, 07:01 last edited by
                  #13

                  @elsa
                  OK, at least that confirms the unresolveds are indeed from your libraries and not from, say, remaining references somewhere to MinGW functions. FWIW, those are "mangled" names which come from references to C++ functions.

                  I think you should work through the points I suggested. In particular it's now unclear how come MinGW ever came into it/worked, since the third-party link you provided talked only about MSVC....

                  1 Reply Last reply
                  0
                  • J JonB
                    22 Aug 2018, 15:36

                    @elsa
                    I'm going to have to bow out, because I haven't used MinGW, I don't use Qt Creator/cmake/C++, someone else may know better than I.

                    I will say, I'm confused, because if the libraries are from that page it only talks about MSVC, so I don't even know how MinGW came into it.

                    I think you should:

                    • Establish what/where your library files, and whether they are MSVC or MinGW.
                    • Make sure however you configure your project to generate linker lines it's using the right linker and command-line options for whatever the correct files for it are. When you changed over from MinGW to MSVC you must have had to re-configure the makes from scratch I imagine, telling it which compiler/linker you're using, I imagine. I don't know, but those link library lines you show still look a bit gcc rather than msvc/link to me, but I could be mistaken.
                    • Make sure your "unresolved"s are not because you are actually trying to call any functions which are not documented as exported from the third-party libraries.
                    • Maybe find a couple of "typical" examples of the "unresolved external symbol errors" you are getting and show them here. It may give us an idea of just what sort of thing it's trying to find.
                    E Offline
                    E Offline
                    elsa
                    wrote on 23 Aug 2018, 07:12 last edited by
                    #14

                    @JonB said in Link external library with MSCV compiler:

                    • Make sure however you configure your project to generate linker lines it's using the right linker and command-line options for whatever the correct files for it are. When you changed over from MinGW to MSVC you must have had to re-configure the makes from scratch I imagine, telling it which compiler/linker you're using, I imagine. I don't know, but those link library lines you show still look a bit gcc rather than msvc/link to me, but I could be mistaken.

                    how does MSCV linking look like? and by "reconfigure" you mean choosing the new kit/compiler and running qmake or is there something else?

                    J 1 Reply Last reply 23 Aug 2018, 07:27
                    0
                    • E elsa
                      23 Aug 2018, 07:12

                      @JonB said in Link external library with MSCV compiler:

                      • Make sure however you configure your project to generate linker lines it's using the right linker and command-line options for whatever the correct files for it are. When you changed over from MinGW to MSVC you must have had to re-configure the makes from scratch I imagine, telling it which compiler/linker you're using, I imagine. I don't know, but those link library lines you show still look a bit gcc rather than msvc/link to me, but I could be mistaken.

                      how does MSCV linking look like? and by "reconfigure" you mean choosing the new kit/compiler and running qmake or is there something else?

                      J Offline
                      J Offline
                      JonB
                      wrote on 23 Aug 2018, 07:27 last edited by JonB
                      #15

                      @elsa
                      I'm not sure about the MSVC command-line. I was thinking it would use LINK and have something like /LIB and/or mention of blas_win32_MT.LIB, I'm niggled by the suspicion it's still trying to link with MinGW libraries, but I'm not sure. You could look at/show the actual linker line that's being executed?

                      Yes, you needed to pick new compiler/linker kit and re-run qmake, or similar. It's very important that you cleaned everything out --- perferably restarted in a clean folder --- as you don't want any artefacts left over from old compiler/configuration. If it were me, at this point I'd be tempted to set up a brand new project in a new directory which just makes a couple of calls to those libraries and get it all working with MSVC from scratch.

                      P.S.
                      blas_win32_MT, lapack_win32_MT: Apart from the fact that you need to check you're compiling & linking your code with /MT, those must be 32-bit libraries. You are compiling your code for 32-bit too, right?

                      E 1 Reply Last reply 23 Aug 2018, 08:01
                      0
                      • J JonB
                        23 Aug 2018, 07:27

                        @elsa
                        I'm not sure about the MSVC command-line. I was thinking it would use LINK and have something like /LIB and/or mention of blas_win32_MT.LIB, I'm niggled by the suspicion it's still trying to link with MinGW libraries, but I'm not sure. You could look at/show the actual linker line that's being executed?

                        Yes, you needed to pick new compiler/linker kit and re-run qmake, or similar. It's very important that you cleaned everything out --- perferably restarted in a clean folder --- as you don't want any artefacts left over from old compiler/configuration. If it were me, at this point I'd be tempted to set up a brand new project in a new directory which just makes a couple of calls to those libraries and get it all working with MSVC from scratch.

                        P.S.
                        blas_win32_MT, lapack_win32_MT: Apart from the fact that you need to check you're compiling & linking your code with /MT, those must be 32-bit libraries. You are compiling your code for 32-bit too, right?

                        E Offline
                        E Offline
                        elsa
                        wrote on 23 Aug 2018, 08:01 last edited by
                        #16

                        @JonB said in Link external library with MSCV compiler:

                        @elsa
                        I'm not sure about the MSVC command-line. I was thinking it would use LINK and have something like /LIB and/or mention of blas_win32_MT.LIB, I'm niggled by the suspicion it's still trying to link with MinGW libraries, but I'm not sure. You could look at/show the actual linker line that's being executed?

                        I thought this is just the line from the .pro file that I linked in the question. Is linking also defined somewhere else?

                        P.S.
                        blas_win32_MT, lapack_win32_MT: Apart from the fact that you need to check you're compiling & linking your code with /MT, those must be 32-bit libraries. You are compiling your code for 32-bit too, right?

                        Okay maybe this is the problem!
                        BIG UPDATE: The above mentioned errors get produced using the 64bit compiler, which -now that you say it- maybe explains why it doesn't work..
                        The weird thing is, however, when running the 32 bit compiler I get the following error:

                        error: LNK1112: module machine type 'x86' conflicts with target machine type 'x64'
                        

                        so I am confused now. Is 32bit or 64bit correct?

                        J 1 Reply Last reply 23 Aug 2018, 08:06
                        0
                        • E elsa
                          23 Aug 2018, 08:01

                          @JonB said in Link external library with MSCV compiler:

                          @elsa
                          I'm not sure about the MSVC command-line. I was thinking it would use LINK and have something like /LIB and/or mention of blas_win32_MT.LIB, I'm niggled by the suspicion it's still trying to link with MinGW libraries, but I'm not sure. You could look at/show the actual linker line that's being executed?

                          I thought this is just the line from the .pro file that I linked in the question. Is linking also defined somewhere else?

                          P.S.
                          blas_win32_MT, lapack_win32_MT: Apart from the fact that you need to check you're compiling & linking your code with /MT, those must be 32-bit libraries. You are compiling your code for 32-bit too, right?

                          Okay maybe this is the problem!
                          BIG UPDATE: The above mentioned errors get produced using the 64bit compiler, which -now that you say it- maybe explains why it doesn't work..
                          The weird thing is, however, when running the 32 bit compiler I get the following error:

                          error: LNK1112: module machine type 'x86' conflicts with target machine type 'x64'
                          

                          so I am confused now. Is 32bit or 64bit correct?

                          J Offline
                          J Offline
                          JonB
                          wrote on 23 Aug 2018, 08:06 last edited by JonB
                          #17

                          @elsa

                          I thought this is just the line from the .pro file that I linked in the question. Is linking also defined somewhere else?

                          All you have shown is a LIBS += ... line in a .pro file. When you compile (link) it must also show the actual command-line it has constructed and is executing using these, presumably in whatever "compiler output window" it has.

                          error: LNK1112: module machine type 'x86' conflicts with target machine type 'x64'

                          so I am confused now. Is 32bit or 64bit correct?

                          x86 means 32-bit, x64 means 64-bit. Assuming from the names that those libraries you have are compiled 32-bit, you must compile everything else 32-bit (or get/compile 64-bit version of the libraries). The fact that you have a message target machine type 'x64' must indicate that somewhere you have told Qt Creator (the .pro file?) that your target is 64-bit, and that does not look good....

                          E 1 Reply Last reply 23 Aug 2018, 08:20
                          0
                          • J JonB
                            23 Aug 2018, 08:06

                            @elsa

                            I thought this is just the line from the .pro file that I linked in the question. Is linking also defined somewhere else?

                            All you have shown is a LIBS += ... line in a .pro file. When you compile (link) it must also show the actual command-line it has constructed and is executing using these, presumably in whatever "compiler output window" it has.

                            error: LNK1112: module machine type 'x86' conflicts with target machine type 'x64'

                            so I am confused now. Is 32bit or 64bit correct?

                            x86 means 32-bit, x64 means 64-bit. Assuming from the names that those libraries you have are compiled 32-bit, you must compile everything else 32-bit (or get/compile 64-bit version of the libraries). The fact that you have a message target machine type 'x64' must indicate that somewhere you have told Qt Creator (the .pro file?) that your target is 64-bit, and that does not look good....

                            E Offline
                            E Offline
                            elsa
                            wrote on 23 Aug 2018, 08:20 last edited by elsa
                            #18

                            @JonB

                            All you have shown is a LIBS += ... line in a .pro file. When you compile (link) it must also show the actual command-line it has constructed and is executing using these, presumably in whatever "compiler output window" it has.

                            link /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /SUBSYSTEM:WINDOWS "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" /MANIFEST:embed /OUT:debug\DecaRangeRTLS.exe @C:\Users\FRHMELSA\AppData\Local\Temp\DecaRangeRTLS.exe.10468.50531.jom
                            

                            x86 means 32-bit, x64 means 64-bit. Assuming from the names that those libraries you have are compiled 32-bit, you must compile everything else 32-bit (or get/compile 64-bit version of the libraries). The fact that you have a message target machine type 'x64' must indicate that somewhere you have told Qt Creator (the .pro file?) that your target is 64-bit, and that does not look good....

                            yes I have reached that assumption as well, but then how do I change the target machine type? :/

                            J J 2 Replies Last reply 23 Aug 2018, 08:34
                            0
                            • E elsa
                              23 Aug 2018, 08:20

                              @JonB

                              All you have shown is a LIBS += ... line in a .pro file. When you compile (link) it must also show the actual command-line it has constructed and is executing using these, presumably in whatever "compiler output window" it has.

                              link /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /SUBSYSTEM:WINDOWS "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" /MANIFEST:embed /OUT:debug\DecaRangeRTLS.exe @C:\Users\FRHMELSA\AppData\Local\Temp\DecaRangeRTLS.exe.10468.50531.jom
                              

                              x86 means 32-bit, x64 means 64-bit. Assuming from the names that those libraries you have are compiled 32-bit, you must compile everything else 32-bit (or get/compile 64-bit version of the libraries). The fact that you have a message target machine type 'x64' must indicate that somewhere you have told Qt Creator (the .pro file?) that your target is 64-bit, and that does not look good....

                              yes I have reached that assumption as well, but then how do I change the target machine type? :/

                              J Offline
                              J Offline
                              JonB
                              wrote on 23 Aug 2018, 08:34 last edited by
                              #19

                              @elsa
                              I don't know in Qt Creator, but it can hardly be difficult, presumably you specify it at some point when you set up your project. Google for it.

                              Unless the error is from one of your libraries already being compiled 64-bit. Check whether those libraries with win32 in them are indeed 32-bit, not 64-bit.

                              Come on, you can do this, I can't answer!

                              1 Reply Last reply
                              1
                              • E elsa
                                23 Aug 2018, 08:20

                                @JonB

                                All you have shown is a LIBS += ... line in a .pro file. When you compile (link) it must also show the actual command-line it has constructed and is executing using these, presumably in whatever "compiler output window" it has.

                                link /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /SUBSYSTEM:WINDOWS "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" /MANIFEST:embed /OUT:debug\DecaRangeRTLS.exe @C:\Users\FRHMELSA\AppData\Local\Temp\DecaRangeRTLS.exe.10468.50531.jom
                                

                                x86 means 32-bit, x64 means 64-bit. Assuming from the names that those libraries you have are compiled 32-bit, you must compile everything else 32-bit (or get/compile 64-bit version of the libraries). The fact that you have a message target machine type 'x64' must indicate that somewhere you have told Qt Creator (the .pro file?) that your target is 64-bit, and that does not look good....

                                yes I have reached that assumption as well, but then how do I change the target machine type? :/

                                J Offline
                                J Offline
                                jsulm
                                Lifetime Qt Champion
                                wrote on 23 Aug 2018, 08:39 last edited by
                                #20

                                @elsa said in Link external library with MSCV compiler:

                                but then how do I change the target machine type?

                                Use Qt for that target machine type

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

                                1 Reply Last reply
                                0
                                • E Offline
                                  E Offline
                                  elsa
                                  wrote on 23 Aug 2018, 11:47 last edited by
                                  #21

                                  @JonB @jsulm @mrjj I will try to start doing all the steps from scratch, because I am getting frustrated and cannot get on with the project because of this linker problem..
                                  I am running Qt5.11.1. So what I read is that it only supports up to VS15, so I installed VS15. Qt, however, did not auto-detect the VS 14.0 compiler, so I had to add it manually. I found the path of the compiler .dll file but Qt also wants a make path (where is it?). This is where I am stuck now. Which make executable do I need for the compiler? and what else am I missing? I am sorry if my questions are to confusing or too easy. I am just trying to understand, because I never dealt with compilers and linkers in detail before and this problem came very unexpected.

                                  J 1 Reply Last reply 23 Aug 2018, 11:53
                                  0
                                  • E elsa
                                    23 Aug 2018, 11:47

                                    @JonB @jsulm @mrjj I will try to start doing all the steps from scratch, because I am getting frustrated and cannot get on with the project because of this linker problem..
                                    I am running Qt5.11.1. So what I read is that it only supports up to VS15, so I installed VS15. Qt, however, did not auto-detect the VS 14.0 compiler, so I had to add it manually. I found the path of the compiler .dll file but Qt also wants a make path (where is it?). This is where I am stuck now. Which make executable do I need for the compiler? and what else am I missing? I am sorry if my questions are to confusing or too easy. I am just trying to understand, because I never dealt with compilers and linkers in detail before and this problem came very unexpected.

                                    J Offline
                                    J Offline
                                    jsulm
                                    Lifetime Qt Champion
                                    wrote on 23 Aug 2018, 11:53 last edited by jsulm
                                    #22

                                    @elsa said in Link external library with MSCV compiler:

                                    So what I read is that it only supports up to VS15

                                    This is wrong - it supports VS17. But since VS15 and VS17 C++ compiler are compatible this does not matter. If you use Qt online installer you will see what compiler Qt 5.11.1 supports.

                                    "but Qt also wants a make path" - can you please tell us exactly what it asks (screen-shot)?

                                    If my understanding is correct the lib you want to use is built for x86, right? Official Qt build for Windows/VS are all x86_64. You will need a x86_64 build of that lib or build it by yourself.

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

                                    E 1 Reply Last reply 23 Aug 2018, 12:18
                                    1
                                    • J jsulm
                                      23 Aug 2018, 11:53

                                      @elsa said in Link external library with MSCV compiler:

                                      So what I read is that it only supports up to VS15

                                      This is wrong - it supports VS17. But since VS15 and VS17 C++ compiler are compatible this does not matter. If you use Qt online installer you will see what compiler Qt 5.11.1 supports.

                                      "but Qt also wants a make path" - can you please tell us exactly what it asks (screen-shot)?

                                      If my understanding is correct the lib you want to use is built for x86, right? Official Qt build for Windows/VS are all x86_64. You will need a x86_64 build of that lib or build it by yourself.

                                      E Offline
                                      E Offline
                                      elsa
                                      wrote on 23 Aug 2018, 12:18 last edited by
                                      #23

                                      @jsulm 0_1535026544645_kitqt.PNG

                                      This is a screenshot of the kit I am using now. This warning made me think that qt only supports VS15, but if it doesn't make a difference, then it's ok. This is now using the autodetected compiler (VS17), so I don't need to set up the path manually.
                                      And yes the library is x86.

                                      J 1 Reply Last reply 23 Aug 2018, 12:20
                                      0
                                      • E elsa
                                        23 Aug 2018, 12:18

                                        @jsulm 0_1535026544645_kitqt.PNG

                                        This is a screenshot of the kit I am using now. This warning made me think that qt only supports VS15, but if it doesn't make a difference, then it's ok. This is now using the autodetected compiler (VS17), so I don't need to set up the path manually.
                                        And yes the library is x86.

                                        J Offline
                                        J Offline
                                        jsulm
                                        Lifetime Qt Champion
                                        wrote on 23 Aug 2018, 12:20 last edited by
                                        #24

                                        @elsa OK, you have 32bit Qt, compiler and lib - does it work now?

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

                                        E 1 Reply Last reply 23 Aug 2018, 12:23
                                        0
                                        • J jsulm
                                          23 Aug 2018, 12:20

                                          @elsa OK, you have 32bit Qt, compiler and lib - does it work now?

                                          E Offline
                                          E Offline
                                          elsa
                                          wrote on 23 Aug 2018, 12:23 last edited by
                                          #25

                                          @jsulm it produces this error:

                                          f:\dd\vctools\crt\vcstartup\src\gs\gs_report.c:220: error: Debugger encountered an exception: Exception at 0xca9b99, code: 0xc0000409: , flags=0x1 (execution cannot be continued)
                                          f:\dd\vctools\crt\vcstartup\src\gs\gs_report.c:220: error: Debugger encountered an exception: Exception at 0xca9b99, code: 0xc0000409: , flags=0x1 (execution cannot be continued)
                                          
                                          J 1 Reply Last reply 23 Aug 2018, 12:27
                                          0

                                          15/34

                                          23 Aug 2018, 07:27

                                          • Login

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