Compiler Error due to Build process
-
@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?
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 :) -
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 :)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. -
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.@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!
-
@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!
@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'
-
@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'
@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)
{
<--- ? -
@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)
{
<--- ?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.
-
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.
-
@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);
-
@socke
maybe the auto dont get it right ?
try with
pv_status_t pv_porcupine_init =
if it complains then try to cast itI 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 -
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 hahahi
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 :)
-
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 :)
@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.
-
@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.