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 Updated to NodeBB v4.3 + New Features

Compiler Error due to Build process

Scheduled Pinned Locked Moved Solved General and Desktop
21 Posts 3 Posters 3.9k Views 2 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.
  • 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