Compiler Error due to Build process
-
wrote on 17 Apr 2020, 06:37 last edited by socke
Hi,
I am currently doing a side project where I am trying to make a home made "Alexa" that simply should change my playback device on my computer. I have managed to programatically change my playback device on MSVC compiler in Qt. The next step is to use Porcupine.
I am including its header pv_porcupine.h and when compiling I get a lot of errors when using Desktop_Qt_5_14_2_MSVC2017_32bit-Debug compiler.Additional files
Picovoice.hMy build steps are:
- Make: jom.exe in ~\qt\build-Project-Desktop_Qt_5_14_2_MSVC2017_32bit-Debug
- qmake: qmake.exe Project.pro -spec win32-msvc "CONFIG+=debug" "CONFIG+=qml_debug"
When I have Make step disabled I managed to get rid of my errors, but I can't change the code, i.e. it does not change upon saving and building.
However when I have both qmake and make in the build steps I get 30 errors.
My ideas:
As stated below, it seems as if there is some issues in the build steps. What I am doing wrong here? Note I am very new to Qt and the whole build process.08:28:24: Running steps for project Project... 08:28:24: Starting: "C:\Qt\Tools\QtCreator\bin\jom.exe" C:\Qt\Tools\QtCreator\bin\jom.exe -f Makefile.Debug cl -c -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus -Zi -MDd -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 -EHsc /Fddebug\Project.vc.pdb -DUNICODE -D_UNICODE -DWIN32 -D_ENABLE_EXTENDED_ALIGNED_STORAGE -DQT_QML_DEBUG -I..\Project -I. -IC:\Qt\5.14.2\msvc2017\mkspecs\win32-msvc -Fodebug\ @C:\Users\user1\AppData\Local\Temp\main.obj.14556.0.jom main.cpp Project\picovoice.h(27): error C3861: 'visibility': identifier not found Project\picovoice.h(27): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int Project\picovoice.h(27): error C2448: '__attribute__': function-style initializer appears to be a function definition Project\picovoice.h(48): error C3861: 'visibility': identifier not found Project\picovoice.h(48): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int Project\picovoice.h(48): error C2374: '__attribute__': redefinition; multiple initialization Project\picovoice.h(27): note: see declaration of '__attribute__' Project\picovoice.h(48): error C2059: syntax error: 'const' Project\pv_porcupine.h(48): error C3861: 'visibility': identifier not found Project\pv_porcupine.h(48): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int Project\pv_porcupine.h(48): error C2374: '__attribute__': redefinition; multiple initialization Project\picovoice.h(27): note: see declaration of '__attribute__' Project\pv_porcupine.h(48): error C2146: syntax error: missing ';' before identifier 'pv_status_t' Project\pv_porcupine.h(60): error C3861: 'visibility': identifier not found Project\pv_porcupine.h(60): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int Project\pv_porcupine.h(60): error C2374: '__attribute__': redefinition; multiple initialization Project\picovoice.h(27): note: see declaration of '__attribute__' Project\pv_porcupine.h(60): error C2448: '__attribute__': function-style initializer appears to be a function definition Project\pv_porcupine.h(60): error C2065: 'pv_porcupine_t': undeclared identifier Project\pv_porcupine.h(60): error C2065: 'object': undeclared identifier Project\pv_porcupine.h(60): error C2182: 'pv_porcupine_delete': illegal use of type 'void' Project\pv_porcupine.h(73): error C3861: 'visibility': identifier not found Project\pv_porcupine.h(73): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int Project\pv_porcupine.h(73): error C2374: '__attribute__': redefinition; multiple initialization Project\picovoice.h(27): note: see declaration of '__attribute__' Project\pv_porcupine.h(73): error C2146: syntax error: missing ';' before identifier 'pv_status_t' Project\pv_porcupine.h(80): error C3861: 'visibility': identifier not found Project\pv_porcupine.h(80): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int Project\pv_porcupine.h(80): error C2374: '__attribute__': redefinition; multiple initialization Project\picovoice.h(27): note: see declaration of '__attribute__' Project\pv_porcupine.h(80): error C2059: syntax error: 'const' Project\pv_porcupine.h(87): error C3861: 'visibility': identifier not found Project\pv_porcupine.h(87): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int Project\pv_porcupine.h(87): error C2374: '__attribute__': redefinition; multiple initialization Project\picovoice.h(27): note: see declaration of '__attribute__' Project\pv_porcupine.h(87): error C2146: syntax error: missing ';' before identifier 'int32_t' jom: Path}Project-Desktop_Qt_5_14_2_MSVC2017_32bit-Debug\Makefile.Debug [debug\main.obj] Error 2 jom: Path\Project-Desktop_Qt_5_14_2_MSVC2017_32bit-Debug\Makefile [debug] Error 2 08:28:25: The process "C:\Qt\Tools\QtCreator\bin\jom.exe" exited with code 2. Error while building/deploying project Project (kit: Desktop Qt 5.14.2 MSVC2017 32bit) The kit Desktop Qt 5.14.2 MSVC2017 32bit has configuration issues which might be the root cause for this problem. When executing step "Make" 08:28:25: Elapsed time: 00:00.
My .pro file:
TEMPLATE = app CONFIG += console c++11 CONFIG -= app_bundle CONFIG -= qt SOURCES += \ main.cpp HEADERS += \ picovoice.h \ pv_porcupine.h
I've asked the Porcupine community but I reckon they have limited resources to help people so I did not get a lot of help from there. Hope you guys might help me better.
Thanks,
Socke -
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)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 !
-
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
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 !
wrote on 17 Apr 2020, 13:12 last edited by@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? :(
-
@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? :(
@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. -
@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.wrote on 18 Apr 2020, 16:20 last edited by socke@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 aboutmain.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
-
@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.wrote on 19 Apr 2020, 15:18 last edited by 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
-
@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
@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. -
@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.wrote on 19 Apr 2020, 17:47 last edited by@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?
-
@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 :)wrote on 19 Apr 2020, 18:15 last edited by sockeHaha 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.wrote on 19 Apr 2020, 19:26 last edited by@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!
wrote on 19 Apr 2020, 19:37 last edited by 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'
-
@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)
{
<--- ?wrote on 19 Apr 2020, 20:10 last edited byHey 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.
@socke
what is line 88 ? -
wrote on 19 Apr 2020, 21:07 last edited by
@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);
-
@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 it -
@socke
maybe the auto dont get it right ?
try with
pv_status_t pv_porcupine_init =
if it complains then try to cast itwrote on 19 Apr 2020, 21:38 last edited byI 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 :)
wrote on 21 Apr 2020, 17:48 last edited by@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.
1/21