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. Compiler Error due to Build process
Forum Update on Monday, May 27th 2025

Compiler Error due to Build process

Scheduled Pinned Locked Moved Solved General and Desktop
21 Posts 3 Posters 3.2k 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.
  • mrjjM Offline
    mrjjM Offline
    mrjj
    Lifetime Qt Champion
    wrote on last edited by
    #2

    Hi
    Im not sure it likes the visual studio compiler.

    I would try with mingw as it seems the code is tagged for gcc.
    (for export to lib)
    (just install the 64 bit Qt mingw. it has compiler included)

    Also the included DLL
    alt text

    have no LIB file so and looking in the examples it seems you must resolve all function calls your self.

    in the demos (for linux) you see

       const char *(*pv_status_to_string)(pv_status_t);
        pv_status_to_string = dlsym(porcupine_library, "pv_status_to_string");
        if ((error = dlerror()) != NULL) {
            fprintf(stderr, "failed to load 'pv_status_to_string' with '%s'.\n", error);
            exit(1);
        }
    
    

    So i think you must do the same on windows. for that, you can use QLibrary.
    https://doc.qt.io/qt-5/qlibrary.html#
    You can get the symbol name looking at the demos for linux.

    Good luck !

    S 1 Reply Last reply
    2
    • mrjjM mrjj

      Hi
      Im not sure it likes the visual studio compiler.

      I would try with mingw as it seems the code is tagged for gcc.
      (for export to lib)
      (just install the 64 bit Qt mingw. it has compiler included)

      Also the included DLL
      alt text

      have no LIB file so and looking in the examples it seems you must resolve all function calls your self.

      in the demos (for linux) you see

         const char *(*pv_status_to_string)(pv_status_t);
          pv_status_to_string = dlsym(porcupine_library, "pv_status_to_string");
          if ((error = dlerror()) != NULL) {
              fprintf(stderr, "failed to load 'pv_status_to_string' with '%s'.\n", error);
              exit(1);
          }
      
      

      So i think you must do the same on windows. for that, you can use QLibrary.
      https://doc.qt.io/qt-5/qlibrary.html#
      You can get the symbol name looking at the demos for linux.

      Good luck !

      S Offline
      S Offline
      socke
      wrote on last edited by
      #3

      @mrjj Problem with MinGw that it does not support uuidof() lookups which MSVC support which I need for PolicyConfig.h to change my default playback device on Windows.

      I get : undefined reference to `_GUID const& __mingw_uuidof<Class>()'
      When I run Nuwens dist of MinGw.

      I managed to set playback device on MSVC compiler in Qt, however, it seems that Porcupine does not? :(

      mrjjM 1 Reply Last reply
      0
      • S socke

        @mrjj Problem with MinGw that it does not support uuidof() lookups which MSVC support which I need for PolicyConfig.h to change my default playback device on Windows.

        I get : undefined reference to `_GUID const& __mingw_uuidof<Class>()'
        When I run Nuwens dist of MinGw.

        I managed to set playback device on MSVC compiler in Qt, however, it seems that Porcupine does not? :(

        mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #4

        @socke said in Compiler Error due to Build process:

        uuidof

        Ah som COM thing. Same should be possible with mingw but i dont know teh Com calls for that.

        well you can try altering
        #define PV_API attribute((visibility ("default")))
        and see if you can get it to compile with VS.

        S 2 Replies Last reply
        1
        • mrjjM mrjj

          @socke said in Compiler Error due to Build process:

          uuidof

          Ah som COM thing. Same should be possible with mingw but i dont know teh Com calls for that.

          well you can try altering
          #define PV_API attribute((visibility ("default")))
          and see if you can get it to compile with VS.

          S Offline
          S Offline
          socke
          wrote on last edited by socke
          #5

          @mrjj said in Compiler Error due to Build process:

          nd see if you can get it to compile with VS.

          I'm not an export on these features but should this do the trick?
          #define PV_API __declspec("default")

          Now I get this issue :S

          main.obj:-1: error: LNK2019: unresolved external symbol "short const * __cdecl get_next_audio_frame(void)" (?get_next_audio_frame@@YAPBFXZ) referenced in function "void __cdecl handleLogic(void)" (?handleLogic@@YAXXZ)
          
          

          It is pointing here:

          extern const int16_t *get_next_audio_frame(void);
          

          According to this place: https://wiki.qt.io/Basics_Of_Plugins

          #define PV_API __declspec(dllexport)
          

          Should do the trick.
          However, now it complains about

          main.obj:-1: error: LNK2019: unresolved external symbol _pv_porcupine_init referenced in function _main
          

          How do I link? I mean I've included it in the header lol

          1 Reply Last reply
          0
          • mrjjM mrjj

            @socke said in Compiler Error due to Build process:

            uuidof

            Ah som COM thing. Same should be possible with mingw but i dont know teh Com calls for that.

            well you can try altering
            #define PV_API attribute((visibility ("default")))
            and see if you can get it to compile with VS.

            S Offline
            S Offline
            socke
            wrote on last edited by socke
            #6

            @mrjj
            OK, I get it now. I need to link the .DLL file which carries the implementation I can receive from declspec().

            win32{
            LIBS += "path.../lib/windows/amd64/libpv_porcupine.dll"
            }

            However, I get

            ...\lib\windows\amd64\libpv_porcupine.dll:-1: error: LNK1107: invalid or corrupt file: cannot read at 0x430
            
            mrjjM 1 Reply Last reply
            0
            • S socke

              @mrjj
              OK, I get it now. I need to link the .DLL file which carries the implementation I can receive from declspec().

              win32{
              LIBS += "path.../lib/windows/amd64/libpv_porcupine.dll"
              }

              However, I get

              ...\lib\windows\amd64\libpv_porcupine.dll:-1: error: LNK1107: invalid or corrupt file: cannot read at 0x430
              
              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by mrjj
              #7

              @socke
              All the linux samples open it manually and resolves the function by code.
              So I assume you must do the same on windows.
              If you are using visual studio compiler, it needs a lib file that tells the methods/exported symbols.
              So Im not sure it will work asking it to link it directly via DLL.
              (even with __declspec( dllimport ) )

              I would try to load it manually with QLibrary and see if that works.
              As far as i understand its a C DLL library so not that dependent on compiler as with c++
              libs but make sure you compile in 64 bit as i think its 64 bit and 32 bit apps dont load 64 bits dlls.

              S 1 Reply Last reply
              1
              • mrjjM mrjj

                @socke
                All the linux samples open it manually and resolves the function by code.
                So I assume you must do the same on windows.
                If you are using visual studio compiler, it needs a lib file that tells the methods/exported symbols.
                So Im not sure it will work asking it to link it directly via DLL.
                (even with __declspec( dllimport ) )

                I would try to load it manually with QLibrary and see if that works.
                As far as i understand its a C DLL library so not that dependent on compiler as with c++
                libs but make sure you compile in 64 bit as i think its 64 bit and 32 bit apps dont load 64 bits dlls.

                S Offline
                S Offline
                socke
                wrote on last edited by
                #8

                @mrjj said in Compiler Error due to Build process:

                far as i understand its a C DLL library so not that dependent on compiler as with c++
                libs but make sure you compile in 64 bit as i think its 64 bit and 32 bit apps dont load 64 bits dlls.

                I understand, too bad __declspec(dllimport) may not work entirely.

                Regarding QLibrary: something like this?

                int main(int argc, char *argv[])
                {
                    QCoreApplication a(argc, argv);
                
                    QLibrary library( "~/lib/windows/amd64/libpv_porcupine.dll" );
                    library.load();
                
                    if( !library.isLoaded() )
                    {
                        qDebug() << "Cannot load library.";
                    } else {
                        qDebug() << "Hello Success" << endl;
                
                    }
                    return a.exec();
                }
                

                Interestingly, with 32-bit I get output "Cannot load library" and 64-bit I get:

                Qt5Cored.lib(Qt5Cored.dll):-1: error: LNK1112: module machine type 'x64' conflicts with target machine type 'x86'
                
                

                So I guess this entails that the library is targeted for 32 bit?

                mrjjM 1 Reply Last reply
                0
                • S socke

                  @mrjj said in Compiler Error due to Build process:

                  far as i understand its a C DLL library so not that dependent on compiler as with c++
                  libs but make sure you compile in 64 bit as i think its 64 bit and 32 bit apps dont load 64 bits dlls.

                  I understand, too bad __declspec(dllimport) may not work entirely.

                  Regarding QLibrary: something like this?

                  int main(int argc, char *argv[])
                  {
                      QCoreApplication a(argc, argv);
                  
                      QLibrary library( "~/lib/windows/amd64/libpv_porcupine.dll" );
                      library.load();
                  
                      if( !library.isLoaded() )
                      {
                          qDebug() << "Cannot load library.";
                      } else {
                          qDebug() << "Hello Success" << endl;
                  
                      }
                      return a.exec();
                  }
                  

                  Interestingly, with 32-bit I get output "Cannot load library" and 64-bit I get:

                  Qt5Cored.lib(Qt5Cored.dll):-1: error: LNK1112: module machine type 'x64' conflicts with target machine type 'x86'
                  
                  

                  So I guess this entails that the library is targeted for 32 bit?

                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #9

                  @socke

                  Hi
                  Yes That sounds like its 32 bit!

                  One thing i did wonder for the "Cannot load library" for 32 bit was the
                  "~/" part but it must work if it can give the other error for 64.
                  I was not aware we could use "~" on Windows :)

                  S 1 Reply Last reply
                  0
                  • mrjjM mrjj

                    @socke

                    Hi
                    Yes That sounds like its 32 bit!

                    One thing i did wonder for the "Cannot load library" for 32 bit was the
                    "~/" part but it must work if it can give the other error for 64.
                    I was not aware we could use "~" on Windows :)

                    S Offline
                    S Offline
                    socke
                    wrote on last edited by socke
                    #10

                    @mrjj

                    Haha I put "~" because I didn't want to show my whole directory structure ;)
                    Btw, the error code I get is:
                    Unknown error 0x000000c1.
                    Which means:

                    0x000000C1
                    ERROR_BAD_EXE_FORMAT
                    %1 is not a valid Win32 application.

                    Based on Win32 Error Codes.

                    This may be relevant. Found a stack post of another person receiving same thing. However, the only answer thought it was a 32/64 bit problem.

                    Weirdest thing is that the lib is under AMD64 on the repository? Very strange indeed.

                    Update 21:19:
                    I have actually made it work, it was due to the compiler being 32 bit, I had to clean and build the project and it worked.

                    Pablo J. RoginaP 1 Reply Last reply
                    1
                    • S socke

                      @mrjj

                      Haha I put "~" because I didn't want to show my whole directory structure ;)
                      Btw, the error code I get is:
                      Unknown error 0x000000c1.
                      Which means:

                      0x000000C1
                      ERROR_BAD_EXE_FORMAT
                      %1 is not a valid Win32 application.

                      Based on Win32 Error Codes.

                      This may be relevant. Found a stack post of another person receiving same thing. However, the only answer thought it was a 32/64 bit problem.

                      Weirdest thing is that the lib is under AMD64 on the repository? Very strange indeed.

                      Update 21:19:
                      I have actually made it work, it was due to the compiler being 32 bit, I had to clean and build the project and it worked.

                      Pablo J. RoginaP Offline
                      Pablo J. RoginaP Offline
                      Pablo J. Rogina
                      wrote on last edited by
                      #11

                      @socke said in Compiler Error due to Build process:

                      I had to clean and build the project and it worked.

                      Glad you solved the issue. Please don't forget to mark your post as such!

                      Upvote the answer(s) that helped you solve the issue
                      Use "Topic Tools" button to mark your post as Solved
                      Add screenshots via postimage.org
                      Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

                      S 1 Reply Last reply
                      0
                      • Pablo J. RoginaP Pablo J. Rogina

                        @socke said in Compiler Error due to Build process:

                        I had to clean and build the project and it worked.

                        Glad you solved the issue. Please don't forget to mark your post as such!

                        S Offline
                        S Offline
                        socke
                        wrote on last edited by socke
                        #12

                        @Pablo-J-Rogina

                        Hi Pablo, it is not necessarily solved just yet. Until I manage to do a proper function call, then I would say it's solved.

                          typedef pv_status_t (*pv_porcupine_init)(const char *,
                                                                   int32_t,
                                                                    const char *const *,
                                                                    const float *,
                                                                    pv_porcupine_t **);
                        
                        pv_status_t pv_porcupine_init = library.resolve("pv_porcupine_init");
                        
                        if (pv_porcupine_init)
                        {
                              pv_porcupine_t *handle;
                              pv_status_t status = pv_porcupine_init(model_path, 1, &keyword_path, &sensitivity, &handle);
                        
                              if (status != PV_STATUS_SUCCESS)
                              {
                                  qDebug() << "PV_STATUS_SUCCESS";
                              }
                          }
                        

                        I am not entirely sure how to do this but I want to load the function pv_porcupine_init().
                        Based on this tutorial, what does this do exactly? And what is that in my scenario? Is pv_status_t correct in my case?

                        typedef void (*MyPrototype)();
                        

                        I keep getting:

                        \main.cpp:81: error: C2440: 'initializing': cannot convert from 'QFunctionPointer' to 'MyPrototype'
                        
                        mrjjM 1 Reply Last reply
                        0
                        • S socke

                          @Pablo-J-Rogina

                          Hi Pablo, it is not necessarily solved just yet. Until I manage to do a proper function call, then I would say it's solved.

                            typedef pv_status_t (*pv_porcupine_init)(const char *,
                                                                     int32_t,
                                                                      const char *const *,
                                                                      const float *,
                                                                      pv_porcupine_t **);
                          
                          pv_status_t pv_porcupine_init = library.resolve("pv_porcupine_init");
                          
                          if (pv_porcupine_init)
                          {
                                pv_porcupine_t *handle;
                                pv_status_t status = pv_porcupine_init(model_path, 1, &keyword_path, &sensitivity, &handle);
                          
                                if (status != PV_STATUS_SUCCESS)
                                {
                                    qDebug() << "PV_STATUS_SUCCESS";
                                }
                            }
                          

                          I am not entirely sure how to do this but I want to load the function pv_porcupine_init().
                          Based on this tutorial, what does this do exactly? And what is that in my scenario? Is pv_status_t correct in my case?

                          typedef void (*MyPrototype)();
                          

                          I keep getting:

                          \main.cpp:81: error: C2440: 'initializing': cannot convert from 'QFunctionPointer' to 'MyPrototype'
                          
                          mrjjM Offline
                          mrjjM Offline
                          mrjj
                          Lifetime Qt Champion
                          wrote on last edited by
                          #13

                          @socke
                          Hi
                          The is typedef pv_status_t (*pv_porcupine_init) ...
                          is the function prototype/definition
                          pv_status_t pv_porcupine_init (...)
                          and then we try to bind it to the actual function in the DLL
                          library.resolve("pv_porcupine_init");

                          so does it go into
                          if (pv_porcupine_init)
                          {
                          <--- ?

                          S 1 Reply Last reply
                          1
                          • mrjjM mrjj

                            @socke
                            Hi
                            The is typedef pv_status_t (*pv_porcupine_init) ...
                            is the function prototype/definition
                            pv_status_t pv_porcupine_init (...)
                            and then we try to bind it to the actual function in the DLL
                            library.resolve("pv_porcupine_init");

                            so does it go into
                            if (pv_porcupine_init)
                            {
                            <--- ?

                            S Offline
                            S Offline
                            socke
                            wrote on last edited by
                            #14

                            @mrjj

                            Hey man, I figured that out.

                            typedef pv_status_t (*MyPrototype)(const char *,
                                                                 int32_t,
                                                                 const char *const *,
                                                                 const float *,
                                                                 pv_porcupine_t **);
                            
                              auto pv_porcupine_init = library.resolve("pv_porcupine_init");
                            
                              if (pv_porcupine_init)
                              {
                                  pv_porcupine_t *handle;
                            
                                  pv_status_t status = pv_porcupine_init(model_path, 1, &keyword_path, &sensitivity, &handle);
                            }
                            
                            >> \main.cpp:88: error: C2197: 'void (__cdecl *)(void)': too many arguments for call
                            

                            Seems as if my typedef declaration is incorrect? From what I can see, it corresponds to the same method in pv_porcupine.h.

                            mrjjM 1 Reply Last reply
                            0
                            • S socke

                              @mrjj

                              Hey man, I figured that out.

                              typedef pv_status_t (*MyPrototype)(const char *,
                                                                   int32_t,
                                                                   const char *const *,
                                                                   const float *,
                                                                   pv_porcupine_t **);
                              
                                auto pv_porcupine_init = library.resolve("pv_porcupine_init");
                              
                                if (pv_porcupine_init)
                                {
                                    pv_porcupine_t *handle;
                              
                                    pv_status_t status = pv_porcupine_init(model_path, 1, &keyword_path, &sensitivity, &handle);
                              }
                              
                              >> \main.cpp:88: error: C2197: 'void (__cdecl *)(void)': too many arguments for call
                              

                              Seems as if my typedef declaration is incorrect? From what I can see, it corresponds to the same method in pv_porcupine.h.

                              mrjjM Offline
                              mrjjM Offline
                              mrjj
                              Lifetime Qt Champion
                              wrote on last edited by
                              #15

                              @socke
                              what is line 88 ?

                              S 1 Reply Last reply
                              0
                              • mrjjM mrjj

                                @socke
                                what is line 88 ?

                                S Offline
                                S Offline
                                socke
                                wrote on last edited by
                                #16

                                @mrjj said in Compiler Error due to Build process:

                                @socke
                                what is line 88 ?

                                Line 88 would be:

                                pv_status_t status = pv_porcupine_init(model_path, 1, &keyword_path, &sensitivity, &handle);
                                
                                mrjjM 1 Reply Last reply
                                0
                                • S socke

                                  @mrjj said in Compiler Error due to Build process:

                                  @socke
                                  what is line 88 ?

                                  Line 88 would be:

                                  pv_status_t status = pv_porcupine_init(model_path, 1, &keyword_path, &sensitivity, &handle);
                                  
                                  mrjjM Offline
                                  mrjjM Offline
                                  mrjj
                                  Lifetime Qt Champion
                                  wrote on last edited by
                                  #17

                                  @socke
                                  maybe the auto dont get it right ?
                                  try with
                                  pv_status_t pv_porcupine_init =
                                  if it complains then try to cast it

                                  S 1 Reply Last reply
                                  0
                                  • mrjjM mrjj

                                    @socke
                                    maybe the auto dont get it right ?
                                    try with
                                    pv_status_t pv_porcupine_init =
                                    if it complains then try to cast it

                                    S Offline
                                    S Offline
                                    socke
                                    wrote on last edited by
                                    #18

                                    @mrjj

                                    I did it :D

                                    typedef pv_status_t (*_pv_porcupine_init)(const char *, int32_t, const char *const *, const float *, pv_porcupine_t **);
                                    
                                       _pv_porcupine_init pv_porcupine_init = (_pv_porcupine_init) library.resolve("pv_porcupine_init");
                                    
                                       if (pv_porcupine_init)
                                       {
                                           pv_porcupine_t *handle;
                                           qDebug() << "PV_STATUS_SUCCESS";
                                    
                                           pv_status_t status = pv_porcupine_init(model_path, 1, &keyword_path, &sensitivity, &handle);
                                    }
                                    

                                    I believe the auto was not casting correctly, I believe (_pv_porcupine_init) fixed it.

                                    Do you know how I know? The compiler said:
                                    [ERROR] loading keyword file #0 failed with 'IO_ERROR'. Which means it called the function and the function returned that error message from my bad input, which is a step forward programmer wise haha

                                    mrjjM 1 Reply Last reply
                                    0
                                    • S socke

                                      @mrjj

                                      I did it :D

                                      typedef pv_status_t (*_pv_porcupine_init)(const char *, int32_t, const char *const *, const float *, pv_porcupine_t **);
                                      
                                         _pv_porcupine_init pv_porcupine_init = (_pv_porcupine_init) library.resolve("pv_porcupine_init");
                                      
                                         if (pv_porcupine_init)
                                         {
                                             pv_porcupine_t *handle;
                                             qDebug() << "PV_STATUS_SUCCESS";
                                      
                                             pv_status_t status = pv_porcupine_init(model_path, 1, &keyword_path, &sensitivity, &handle);
                                      }
                                      

                                      I believe the auto was not casting correctly, I believe (_pv_porcupine_init) fixed it.

                                      Do you know how I know? The compiler said:
                                      [ERROR] loading keyword file #0 failed with 'IO_ERROR'. Which means it called the function and the function returned that error message from my bad input, which is a step forward programmer wise haha

                                      mrjjM Offline
                                      mrjjM Offline
                                      mrjj
                                      Lifetime Qt Champion
                                      wrote on last edited by
                                      #19

                                      hi
                                      the most exciting part is if you see the
                                      qDebug() << "PV_STATUS_SUCCESS"; ?

                                      Well this has always been a bit hairy, i mean manual resolving function addresses from a DLL :)

                                      S 1 Reply Last reply
                                      0
                                      • mrjjM mrjj

                                        hi
                                        the most exciting part is if you see the
                                        qDebug() << "PV_STATUS_SUCCESS"; ?

                                        Well this has always been a bit hairy, i mean manual resolving function addresses from a DLL :)

                                        S Offline
                                        S Offline
                                        socke
                                        wrote on last edited by
                                        #20

                                        @mrjj
                                        Yes, I will mark this as solved now.
                                        However, you do know what is the most pain? I just realized that there exists no free open source trigger word detection repository :( apparently, the audio files you use for Porcupine expires after 30 days, in that sense, it's still free but I don't want to manually update my audio files.

                                        Thanks a lot for the help btw.

                                        mrjjM 1 Reply Last reply
                                        0
                                        • S socke

                                          @mrjj
                                          Yes, I will mark this as solved now.
                                          However, you do know what is the most pain? I just realized that there exists no free open source trigger word detection repository :( apparently, the audio files you use for Porcupine expires after 30 days, in that sense, it's still free but I don't want to manually update my audio files.

                                          Thanks a lot for the help btw.

                                          mrjjM Offline
                                          mrjjM Offline
                                          mrjj
                                          Lifetime Qt Champion
                                          wrote on last edited by
                                          #21

                                          @socke

                                          Victory !

                                          Hmm. That is good to know and a big bummer for you.
                                          So was not such huge joy even you won and got it to work.
                                          On the bright side, you learn alot about linking.

                                          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