Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. 3rd Party Software
  4. Link Qt program with DLLs
Forum Updated to NodeBB v4.3 + New Features

Link Qt program with DLLs

Scheduled Pinned Locked Moved Solved 3rd Party Software
4 Posts 3 Posters 786 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.
  • T Offline
    T Offline
    Tiago M.Pinto
    wrote on last edited by
    #1

    Hi,

    I am struggling trying to link my Qt program with some 3rd party DLLs.

    I use minGW compiler in Qt and the DLLs were compilied with MSVC 2017 (I think). The DLLs have C linkage (with extern "C") and they use __declspec(dllexport) in the functions to be exported.

    The way I try to use the DLLs is simply by adding in Qt creator an external library using the .lib and .h files path of the DLLs. Then, having the DLLs in the same directory as my executable, my program is always crashing even before it starts my mainwindow.

    As alternative, I also tried to compile my program with MSVC 2019 but I couldn't configure the kit in order to use this compiler with Qt MSVC 2017.

    Any suggestions?

    sierdzioS 1 Reply Last reply
    0
    • T Tiago M.Pinto

      Hi,

      I am struggling trying to link my Qt program with some 3rd party DLLs.

      I use minGW compiler in Qt and the DLLs were compilied with MSVC 2017 (I think). The DLLs have C linkage (with extern "C") and they use __declspec(dllexport) in the functions to be exported.

      The way I try to use the DLLs is simply by adding in Qt creator an external library using the .lib and .h files path of the DLLs. Then, having the DLLs in the same directory as my executable, my program is always crashing even before it starts my mainwindow.

      As alternative, I also tried to compile my program with MSVC 2019 but I couldn't configure the kit in order to use this compiler with Qt MSVC 2017.

      Any suggestions?

      sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      @Tiago-M-Pinto said in Link Qt program with DLLs:

      I use minGW compiler in Qt and the DLLs were compilied with MSVC 2017 (I think). The DLLs have C linkage (with extern "C") and they use __declspec(dllexport) in the functions to be exported.

      MinGW and MSVC libraries are not compatible. It won't work.

      As alternative, I also tried to compile my program with MSVC 2019 but I couldn't configure the kit in order to use this compiler with Qt MSVC 2017

      I think MSVC 2017 and 2019 are binary compatible so it should work if you compile with 2019 but use libs compiled by 2017.

      (Z(:^

      T 1 Reply Last reply
      2
      • sierdzioS sierdzio

        @Tiago-M-Pinto said in Link Qt program with DLLs:

        I use minGW compiler in Qt and the DLLs were compilied with MSVC 2017 (I think). The DLLs have C linkage (with extern "C") and they use __declspec(dllexport) in the functions to be exported.

        MinGW and MSVC libraries are not compatible. It won't work.

        As alternative, I also tried to compile my program with MSVC 2019 but I couldn't configure the kit in order to use this compiler with Qt MSVC 2017

        I think MSVC 2017 and 2019 are binary compatible so it should work if you compile with 2019 but use libs compiled by 2017.

        T Offline
        T Offline
        Tiago M.Pinto
        wrote on last edited by Tiago M.Pinto
        #3

        Hi @sierdzio, thank you for your reply.

        MinGW and MSVC libraries are not compatible. It won't work.

        OK, I will use MSVC.

        I think MSVC 2017 and 2019 are binary compatible so it should work if you compile with 2019 but use libs compiled by 2017.

        I just got the information that the DLLs were compiled using Visual Studio 2012 (I don't know specifically which compiler). Nevertheless, I tried a simple test consisting in calling a function in one of those DLLs using a Qt program compiled with MSVC 2019 and it still crashes. Could it be a compiler version issue?

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

          @Tiago-M-Pinto said in Link Qt program with DLLs:

          Could it be a compiler version issue?

          @sierdzio already told you that only msvc2017 and 2019 are binary compatible. So recompile your lib with 2107 or 2019 and see if it still crashes - if it is the case take a look at the backtrace to see what goes wrong.

          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

          • Login

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