Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Link a library with Qt on windows
QtWS25 Last Chance

Link a library with Qt on windows

Scheduled Pinned Locked Moved Solved Installation and Deployment
windowsmingw32makelib
7 Posts 3 Posters 5.4k 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.
  • D Offline
    D Offline
    dridk2
    wrote on 27 Dec 2016, 20:17 last edited by dridk2
    #1

    Hi,

    I m trying to port a simple Qt application from linux to windows which depends one library. https://github.com/labsquare/CuteVCF
    The librarie is a C library. ( https://github.com/samtools/htslib) . I create the library by running "make". Everything works on Linux.

    From Windows ( Windows 10), I compiled the library from cygwin and mingw32. This makes me libhts.so and libhts.a .
    I tried to link the libhts.a file using the following command :

     LIBS += -L$$PWD/htslib-1.3.2/ -lhts
     INCLUDEPATH += $$PWD/htslib-1.3.2
     DEPENDPATH += $$PWD/htslib-1.3.2
    

    But it returns me error.. It seems it doesn't link my library .... Maybe it looks for a dll file ? I m confused now about *a *.so *.lib and *.dll file...
    Any help will be welcome !

    /cygdrive/c/Dev/test/htslib-1.3.2/hts_internal.h:45: undefined reference to `__locale_ctype_ptr'
    C:\Dev\test\htslib-1.3.2/libhts.a(hts.o): In function `decompress_peek':
    /cygdrive/c/Dev/test/htslib-1.3.2/hts.c:141: undefined reference to `inflateInit2_'
    /cygdrive/c/Dev/test/htslib-1.3.2/hts.c:144: undefined reference to `inflate'
    /cygdrive/c/Dev/test/htslib-1.3.2/hts.c:147: undefined reference to `inflateEnd'
    /cygdrive/c/Dev/test/htslib-1.3.2/hts.c:147: undefined reference to `inflateEnd'
    C:\Dev\test\htslib-1.3.2/libhts.a(hts.o): In function `test_and_fetch':
    /cygdrive/c/Dev/test/htslib-1.3.2/hts.c:2010: undefined reference to `__getreent'
    /cygdrive/c/Dev/test/htslib-1.3.2/hts.c:2005: undefined reference to `__getreent'
    /cygdrive/c/Dev/test/htslib-1.3.2/hts.c:2001: undefined reference to `__getreent'
    C:\Dev\test\htslib-1.3.2/libhts.a(hts.o): In function `ks_getuntil2':
    /cygdrive/c/Dev/test/htslib-1.3.2/hts.c:47: undefined reference to `__locale_ctype_ptr'
    /cygdrive/c/Dev/test/htslib-1.3.2/hts.c:47: undefined reference to `__locale_ctype_ptr'
    C:\Dev\test\htslib-1.3.2/libhts.a(hts.o): In function `hts_opt_add':
    /cygdrive/c/Dev/test/htslib-1.3.2/hts.c:531: undefined reference to `__getreent'
    C:\Dev\test\htslib-1.3.2/libhts.a(hts.o): In function `tolower_c':
    /cygdrive/c/Dev/test/htslib-1.3.2/hts_internal.h:51: undefined reference to `__locale_ctype_ptr'
    C:\Dev\test\htslib-1.3.2/libhts.a(hts.o): In function `hts_close':
    /cygdrive/c/Dev/test/htslib-1.3.2/hts.c:861: undefined reference to `__errno'
    /cygdrive/c/Dev/test/htslib-1.3.2/hts.c:866: undefined reference to `__errno'
    /cygdrive/c/Dev/test/htslib-1.3.2/hts.c:827: undefined reference to `__getreent'
    C:\Dev\test\htslib-1.3.2/libhts.a(hts.o): In function `hts_hopen':
    
    1 Reply Last reply
    0
    • D Offline
      D Offline
      dridk2
      wrote on 29 Dec 2016, 09:42 last edited by
      #6

      I finally success !
      I compile my library with msys-mingw ! And configure qt creator to use msys-mingw too !
      It works like a charm !

      A 1 Reply Last reply 29 Dec 2016, 19:14
      0
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 27 Dec 2016, 21:40 last edited by
        #2

        Hi,

        Are you also using a MinGW32 based Qt ?

        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
        • D Offline
          D Offline
          dridk2
          wrote on 27 Dec 2016, 23:53 last edited by
          #3

          Yes...
          I think i had some misunderstanding..
          Compiling with cygwin means for cygwin not for windows.
          Compiling with mingw means for windows.

          A 1 Reply Last reply 28 Dec 2016, 00:06
          0
          • D dridk2
            27 Dec 2016, 23:53

            Yes...
            I think i had some misunderstanding..
            Compiling with cygwin means for cygwin not for windows.
            Compiling with mingw means for windows.

            A Offline
            A Offline
            ambershark
            wrote on 28 Dec 2016, 00:06 last edited by ambershark
            #4

            @dridk2 Those errors are caused by mixing libraries that are incompatible. If you compiled that lib for cygwin, then you need to build everything with/for cygwin. Qt/your app/all libs. If you made it with mingw then you need to use that on all your libs (including Qt).

            Likewise bit size matters, so if you used mingw64 and mixed with mingw32 that won't work either.

            And finally .lib/.dll are MSVC extensions. If you are using cygwin or mingw you will have .a/.so.

            From the sounds of it, you are mixing cygwin (hts lib) and mingw (qt/yourapp). Recompile the hts lib with mingw (no cygwin) and you should be fine. Assuming bit size is the same.

            My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

            D 1 Reply Last reply 28 Dec 2016, 14:28
            2
            • A ambershark
              28 Dec 2016, 00:06

              @dridk2 Those errors are caused by mixing libraries that are incompatible. If you compiled that lib for cygwin, then you need to build everything with/for cygwin. Qt/your app/all libs. If you made it with mingw then you need to use that on all your libs (including Qt).

              Likewise bit size matters, so if you used mingw64 and mixed with mingw32 that won't work either.

              And finally .lib/.dll are MSVC extensions. If you are using cygwin or mingw you will have .a/.so.

              From the sounds of it, you are mixing cygwin (hts lib) and mingw (qt/yourapp). Recompile the hts lib with mingw (no cygwin) and you should be fine. Assuming bit size is the same.

              D Offline
              D Offline
              dridk2
              wrote on 28 Dec 2016, 14:28 last edited by
              #5

              @ambershark Thanks ! I will try it ! It seems clear now!

              1 Reply Last reply
              0
              • D Offline
                D Offline
                dridk2
                wrote on 29 Dec 2016, 09:42 last edited by
                #6

                I finally success !
                I compile my library with msys-mingw ! And configure qt creator to use msys-mingw too !
                It works like a charm !

                A 1 Reply Last reply 29 Dec 2016, 19:14
                0
                • D dridk2
                  29 Dec 2016, 09:42

                  I finally success !
                  I compile my library with msys-mingw ! And configure qt creator to use msys-mingw too !
                  It works like a charm !

                  A Offline
                  A Offline
                  ambershark
                  wrote on 29 Dec 2016, 19:14 last edited by
                  #7

                  @dridk2 Great news! Happy coding. :)

                  My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

                  1 Reply Last reply
                  0

                  7/7

                  29 Dec 2016, 19:14

                  • Login

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