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. ANT+ integration in my QT project
Forum Updated to NodeBB v4.3 + New Features

ANT+ integration in my QT project

Scheduled Pinned Locked Moved General and Desktop
23 Posts 2 Posters 10.1k 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.
  • N Offline
    N Offline
    NicuPopescu
    wrote on last edited by
    #13

    first, you need to compile the whole ANT_Windows_Library_Package_v3.2, then in ANT_Windows_Library_Package_v3.2/Debug you'll find the dll(ANT_DLL.dll) its export library ANT_DLL.lib and the static library ANT_Lib.lib for static building(no dll used)

    DEMO_DLL uses ANT_DLL.dll and ANT_DLL.lib which is just an export library for dll and other few .lib files (see Additional Dependencies in VS project Linker->Input)

    DEMO_LIB uses ANT_Lib.lib which is a static library(all static code will be in DEMO_LIB.exe) and check how big is its size compared to ANT_DLL.lib

    1 Reply Last reply
    0
    • M Offline
      M Offline
      maximus
      wrote on last edited by
      #14

      Oh i'm starting to understand.

      I have compiled the whole project "ANT_Windows_Library_Package_v3.2", In the debug folder, I have the lib you mentioned. Now let's say I want to use "ANT_LIB.lib" in a Demo project I just created, how do you actually use the "ANT_LIB.lib" in another project? I have tried the below project; Demo Project.pro, that is actually the project DEMO_LIB that I imported in QtCreator),
      Thanks very much, tell me you paypal account for your payment :)

      So what is the difference between using a static lib or a dll? I will probably use the static lib since it seems easier for me (I don't mind the bigger size)

      Demo Project.pro
      @------------------------------

      TEMPLATE = app
      CONFIG += console
      CONFIG -= app_bundle
      CONFIG -= qt

      #DEFINES -= UNICODE

      #No longer used (use static library ANT_Lib.lib compiled with VisualStudio Express)
      #include (inc/inc.pri)
      #include (libraries/libraries.pri)
      #include (common/common.pri)
      #include (software/ANTFS/ANTFS.pri)
      #include (software/serial/serial.pri)
      #include (software/serial/device_management/device_management.pri)
      #include (software/system/system.pri)
      #include (software/USB/USB.pri)
      #include (software/USB/device_handles/device_handles.pri)
      #include (software/USB/devices/devices.pri)

      SOURCES += demo.cpp

      HEADERS += demo.h

      LIBS += -LC:\Users\Toto\Desktop\ANT_Windows_Library_Package_v3.2\Debug
      INCLUDEPATH += C:\Users\Toto\Desktop\ANT_Windows_Library_Package_v3.2\Debug

      @

      "C:\QT\Qtworkspace\ANT_LIB\demo.h:13: error: C1083: Cannot open include file: 'types.h': No such file or directory"


      Free Indoor Cycling Software - https://maximumtrainer.com

      1 Reply Last reply
      0
      • M Offline
        M Offline
        maximus
        wrote on last edited by
        #15

        I linked the static library ANT_LIB.lib in my pro file

        New Demo_lib.pro :

        @TEMPLATE = app
        CONFIG += console
        CONFIG -= app_bundle
        CONFIG -= qt

        SOURCES += demo.cpp

        HEADERS += demo.h

        #LIBS += -LC:\Users\Toto\Desktop\ANT_Windows_Library_Package_v3.2\Debug\lib
        INCLUDEPATH += C:\Users\Toto\Desktop\ANT_Windows_Library_Package_v3.2\ANT_LIB\inc
        INCLUDEPATH += C:\Users\Toto\Desktop\ANT_Windows_Library_Package_v3.2\ANT_LIB\software\serial
        INCLUDEPATH += C:\Users\Toto\Desktop\ANT_Windows_Library_Package_v3.2\ANT_LIB\software\system
        INCLUDEPATH += C:\Users\Toto\Desktop\ANT_Windows_Library_Package_v3.2\ANT_LIB\software\USB\devices
        INCLUDEPATH += C:\Users\Toto\Desktop\ANT_Windows_Library_Package_v3.2\ANT_LIB\software\USB\device_handles
        INCLUDEPATH += C:\Users\Toto\Desktop\ANT_Windows_Library_Package_v3.2\ANT_LIB\software\USB

        win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../Users/Toto/Desktop/ANT_Windows_Library_Package_v3.2/Debug/lib/ -lANT_LIB
        else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../Users/Toto/Desktop/ANT_Windows_Library_Package_v3.2/Debug/lib/ -lANT_LIBd
        else:unix: LIBS += -L$$PWD/../../../Users/Toto/Desktop/ANT_Windows_Library_Package_v3.2/Debug/lib/ -lANT_LIB

        INCLUDEPATH += $$PWD/../../../Users/Toto/Desktop/ANT_Windows_Library_Package_v3.2/Debug
        DEPENDPATH += $$PWD/../../../Users/Toto/Desktop/ANT_Windows_Library_Package_v3.2/Debug

        win32:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/../../../Users/Toto/Desktop/ANT_Windows_Library_Package_v3.2/Debug/lib/ANT_LIB.lib
        else:win32:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/../../../Users/Toto/Desktop/ANT_Windows_Library_Package_v3.2/Debug/lib/ANT_LIBd.lib
        else:unix: PRE_TARGETDEPS += $$PWD/../../../Users/Toto/Desktop/ANT_Windows_Library_Package_v3.2/Debug/lib/libANT_LIB.a@

        Now I have error like :
        ANT_LIB.lib(dsi_serial_generic.obj):-1: error: LNK2038: mismatch detected for '_MSC_VER': value '1800' doesn't match value '1600' in demo.obj
        This seems to be because the static lib was compiled with VStudio express 2013, not the same compiler that QtCreator use
        "Reference":http://stackoverflow.com/questions/16703401/visual-studio-2010-mismatch-detected-msc-ver-value-doesnt-match


        Free Indoor Cycling Software - https://maximumtrainer.com

        1 Reply Last reply
        0
        • M Offline
          M Offline
          maximus
          wrote on last edited by
          #16

          I did compile ANT_LIB successfully with QTCreator using this setup :

          ANT_LIB.pro
          @---------------

          QT -= gui

          TARGET = ANT_LIB
          TEMPLATE = lib

          CONFIG += staticlib

          DEFINES -= UNICODE

          include (inc/inc.pri)
          include (libraries/libraries.pri)
          include (common/common.pri)
          include (software/ANTFS/ANTFS.pri)
          include (software/serial/serial.pri)
          include (software/serial/device_management/device_management.pri)
          include (software/system/system.pri)
          include (software/USB/USB.pri)
          include (software/USB/device_handles/device_handles.pri)
          include (software/USB/devices/devices.pri)
          @

          When I try to run DEMO_LIB, I now get this error message :
          ANT_LIB.lib(WinDevice.obj):-1: error: LNK2019: unresolved external symbol __imp__CharNextA@4 referenced in function "struct IdEntry __cdecl GetIdType(char const *)" (?GetIdType@@YA?AUIdEntry@@PBD@Z)

          Almost there! I learned a lot today, sorry for the spam, just keeping a log for myself/maybe to help others


          Free Indoor Cycling Software - https://maximumtrainer.com

          1 Reply Last reply
          0
          • N Offline
            N Offline
            NicuPopescu
            wrote on last edited by
            #17

            ANT_LIB.lib may compile but this does not necessarily mean that was linked correct to all required dependent libs: I mean this might be discovered later when other project is compiled against it and does calls to lib functions calling farther other functions from other libs .... is recommended to understand into which libs the unreferenced functions reside and take care the all libs where added in LIBS while compiling ANT_LIB

            1 Reply Last reply
            0
            • M Offline
              M Offline
              maximus
              wrote on last edited by
              #18

              Thanks Nicu, I am on my way to debugging this error

              _ANT_LIB.lib(WinDevice.obj):-1: error: LNK2019: unresolved external symbol ___imp__CharNextA@4 referenced in function "struct IdEntry cdecl GetIdType(char const *)" (?GetIdType@@YA?AUIdEntry@@PBD@Z)

              Function GetIdType :

              @IdEntry GetIdType(LPCTSTR Id)
              {
              IdEntry Entry;

              Entry.InstanceId = FALSE;
              Entry.Wild = NULL;
              Entry.String = Id;
              
              if(Entry.String[0] == INSTANCEID_PREFIX_CHAR)
              

              {
              Entry.InstanceId = TRUE;
              Entry.String = CharNext(Entry.String); //-- Function causing the error!
              }
              if(Entry.String[0] == QUOTE_PREFIX_CHAR)
              {
              Entry.String = CharNext(Entry.String);
              }
              else
              {
              Entry.Wild = _tcschr(Entry.String,WILD_CHAR);
              }
              return Entry;
              }@

              Define CharNext:

              @WINUSERAPI
              LPSTR
              WINAPI
              CharNextA(
              __in LPCSTR lpsz);
              WINUSERAPI
              LPWSTR
              WINAPI
              CharNextW(
              __in LPCWSTR lpsz);
              #ifdef UNICODE
              #define CharNext CharNextW
              #else
              #define CharNext CharNextA
              #endif // !UNICODE@

              Error seems to be related to User32.dll, haven't found where to put this file yet...
              Thanks


              Free Indoor Cycling Software - https://maximumtrainer.com

              1 Reply Last reply
              0
              • N Offline
                N Offline
                NicuPopescu
                wrote on last edited by
                #19

                as I told you, you need in LIBS also user32.lib, no need to take care where is User32.dll : as other sys dlls it is in Windows system directory (i.e. C:\Windows\system32 on XP) which is one of the searched path for a required dll

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  maximus
                  wrote on last edited by
                  #20

                  I added User32.lib in the .pro of DEMO_LIB project (if I add it to ANT_LIB, DEMO_LIB would not build, possible to bundle a lib inside a static lib?)

                  How can I find all the lib dependency of project ANT_LIB? I have checked inside the visual studio project file, and couldn't find anything related to User32.lib

                  I now get a new error :
                  ANT_LIB.lib(WinDevice.obj):-1: error: LNK2019: unresolved external symbol imp__RegQueryValueExA@24 referenced in function "char * * cdecl GetRegMultiSz(struct HKEY *,char const *)" (?GetRegMultiSz@@YAPAPADPAUHKEY@@PBD@Z)

                  line of code in cause :
                  @while(RegQueryValueEx(hKey,Val,NULL,&dataType,(PBYTE)buffer,&reqSize) != NO_ERROR) {...}@

                  Define RegQueryValueEx :
                  @WINADVAPI
                  LSTATUS
                  APIENTRY
                  RegQueryValueExA (
                  __in HKEY hKey,
                  __in_opt LPCSTR lpValueName,
                  __reserved LPDWORD lpReserved,
                  __out_opt LPDWORD lpType,
                  __out_bcount_part_opt(*lpcbData, *lpcbData) __out_data_source(REGISTRY) LPBYTE lpData,
                  __inout_opt LPDWORD lpcbData
                  );
                  WINADVAPI
                  LSTATUS
                  APIENTRY
                  RegQueryValueExW (
                  __in HKEY hKey,
                  __in_opt LPCWSTR lpValueName,
                  __reserved LPDWORD lpReserved,
                  __out_opt LPDWORD lpType,
                  __out_bcount_part_opt(*lpcbData, *lpcbData) __out_data_source(REGISTRY) LPBYTE lpData,
                  __inout_opt LPDWORD lpcbData
                  );
                  #ifdef UNICODE
                  #define RegQueryValueEx RegQueryValueExW
                  #else
                  #define RegQueryValueEx RegQueryValueExA
                  #endif // !UNICODE@

                  DEMO_LIB.pro
                  @TEMPLATE = app
                  CONFIG += console
                  CONFIG -= app_bundle
                  CONFIG -= qt

                  SOURCES += demo.cpp

                  HEADERS += demo.h

                  INCLUDEPATH += C:\Users\Toto\Desktop\ANT_Windows_Library_Package_v3.2\ANT_LIB\inc
                  INCLUDEPATH += C:\Users\Toto\Desktop\ANT_Windows_Library_Package_v3.2\ANT_LIB\software\serial
                  INCLUDEPATH += C:\Users\Toto\Desktop\ANT_Windows_Library_Package_v3.2\ANT_LIB\software\system
                  INCLUDEPATH += C:\Users\Toto\Desktop\ANT_Windows_Library_Package_v3.2\ANT_LIB\software\USB\devices
                  INCLUDEPATH += C:\Users\Toto\Desktop\ANT_Windows_Library_Package_v3.2\ANT_LIB\software\USB\device_handles
                  INCLUDEPATH += C:\Users\Toto\Desktop\ANT_Windows_Library_Package_v3.2\ANT_LIB\software\USB

                  LIBS += "C:\Users\Toto\Desktop\ANT_Windows_Library_Package_v3.2\Debug\lib\ANT_LIB.lib"
                  LIBS += "C:\Users\Toto\Desktop\LIBWIN\winv6.3_um_x86\User32.Lib"
                  @


                  Free Indoor Cycling Software - https://maximumtrainer.com

                  1 Reply Last reply
                  0
                  • N Offline
                    N Offline
                    NicuPopescu
                    wrote on last edited by
                    #21

                    @LIBS+=C:\Users\Toto\Desktop\ANT_Windows_Library_Package_v3.2\Debug\lib\ANT_LIB.lib
                    User32.Lib@

                    "RegQueryValueEx function":http://msdn.microsoft.com/en-us/library/windows/desktop/ms724911(v=vs.85).aspx

                    you need Advapi32.lib

                    this the comand line for linker in DEMO_LIB:

                    /OUT:"D:\Coolstream\Qt\Studiu\ANT\ANT_Windows_Library_Package_v3.2\Debug\DEMO_LIB.exe" /INCREMENTAL /NOLOGO /LIBPATH:"D:\Coolstream\Qt\Studiu\ANT\ANT_Windows_Library_Package_v3.2\Debug" "ANT_LIB.lib" "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" "D:\Coolstream\Qt\Studiu\ANT\ANT_Windows_Library_Package_v3.2\Debug\ANT_Lib.lib" /MANIFEST /ManifestFile:"Debug\DEMO_LIB.exe.intermediate.manifest" /ALLOWISOLATION /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"D:\Coolstream\Qt\Studiu\ANT\ANT_Windows_Library_Package_v3.2\Debug\DEMO_LIB.pdb" /SUBSYSTEM:CONSOLE /PGD:"D:\Coolstream\Qt\Studiu\ANT\ANT_Windows_Library_Package_v3.2\Debug\DEMO_LIB.pgd" /TLBID:1 /DYNAMICBASE /NXCOMPAT /MACHINE:X86 /ERRORREPORT:QUEUE

                    see in LIBPATH how many .lib it seems needed

                    1 Reply Last reply
                    0
                    • M Offline
                      M Offline
                      maximus
                      wrote on last edited by
                      #22

                      Thanks Nicu, finally the demo is working!!
                      I used Dependecy Walker and found that DEMO_LIB.exe uses KERNEL32.DLL, USER32.DLL, ADVAPI32.DLL, MSVCP120D.DLL and MSVCR120D.DLL

                      I Just added Advapi32.lib, should I add the others also?

                      Here is my working DEMO_LIB.pro file:
                      @TEMPLATE = app
                      CONFIG += console
                      CONFIG -= app_bundle
                      CONFIG -= qt

                      SOURCES += demo.cpp

                      HEADERS += demo.h

                      INCLUDEPATH += C:\Users\Toto\Desktop\ANT_Windows_Library_Package_v3.2\ANT_LIB\inc
                      INCLUDEPATH += C:\Users\Toto\Desktop\ANT_Windows_Library_Package_v3.2\ANT_LIB\software\serial
                      INCLUDEPATH += C:\Users\Toto\Desktop\ANT_Windows_Library_Package_v3.2\ANT_LIB\software\system
                      INCLUDEPATH += C:\Users\Toto\Desktop\ANT_Windows_Library_Package_v3.2\ANT_LIB\software\USB\devices
                      INCLUDEPATH += C:\Users\Toto\Desktop\ANT_Windows_Library_Package_v3.2\ANT_LIB\software\USB\device_handles
                      INCLUDEPATH += C:\Users\Toto\Desktop\ANT_Windows_Library_Package_v3.2\ANT_LIB\software\USB

                      LIBS += "C:\Users\Toto\Desktop\ANT_Windows_Library_Package_v3.2\Debug\lib\ANT_LIB.lib"
                      LIBS += "C:\Program Files (x86)\Windows Kits\8.1\Lib\winv6.3\um\x86\User32.lib"
                      LIBS += "C:\Program Files (x86)\Windows Kits\8.1\Lib\winv6.3\um\x86\AdvAPI32.Lib"@

                      I will not have to ship these 2 libs with my application right? as all the windows system have it?
                      Thank you a million time!


                      Free Indoor Cycling Software - https://maximumtrainer.com

                      1 Reply Last reply
                      0
                      • N Offline
                        N Offline
                        NicuPopescu
                        wrote on last edited by
                        #23

                        congrats! :)

                        normally you don't need to deploy those dlls

                        you missed my suggestion to use only once LIBS+= all libs space separated

                        or

                        LIBS+= lib1
                        lib2
                        ...

                        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