Qt app compile error.
-
wrote on 29 Oct 2015, 22:21 last edited by
Hi
Im a starter in Qt. Im use a third party library(TobiiGazeSdk) in my Qt app, and i get compile error, but dont know what is the problem. I need some help. Thank a lot.
This is the output error:mainwindow.obj : error LNK2005: "void * __cdecl xthread_create(void *,void *)" (?xthread_create@@YAPAXPAX0@Z) already defined in main.obj
mainwindow.obj : error LNK2005: "void __cdecl xthread_join(void *)" (?xthread_join@@YAXPAX@Z) already defined in main.obj
mainwindow.obj : error LNK2005: "void __cdecl xinitialize_cv(struct xcondition_variable *)" (?xinitialize_cv@@YAXPAUxcondition_variable@@@Z) already defined in main.obj
mainwindow.obj : error LNK2005: "int __cdecl xwait_until_ready(struct xcondition_variable *)" (?xwait_until_ready@@YAHPAUxcondition_variable@@@Z) already defined in main.obj
mainwindow.obj : error LNK2005: "void __cdecl xsignal_ready(struct xcondition_variable *)" (?xsignal_ready@@YAXPAUxcondition_variable@@@Z) already defined in main.obj
mainwindow.obj : error LNK2005: "void __cdecl report_and_exit_on_error(enum tobiigaze_error_code,char const *)" (?report_and_exit_on_error@@YAXW4tobiigaze_error_code@@PBD@Z) already defined in main.obj
tobii.obj : error LNK2005: "void * __cdecl xthread_create(void *,void *)" (?xthread_create@@YAPAXPAX0@Z) already defined in main.obj
tobii.obj : error LNK2005: "void __cdecl xthread_join(void *)" (?xthread_join@@YAXPAX@Z) already defined in main.obj
tobii.obj : error LNK2005: "void __cdecl xinitialize_cv(struct xcondition_variable *)" (?xinitialize_cv@@YAXPAUxcondition_variable@@@Z) already defined in main.obj
tobii.obj : error LNK2005: "int __cdecl xwait_until_ready(struct xcondition_variable *)" (?xwait_until_ready@@YAHPAUxcondition_variable@@@Z) already defined in main.obj
tobii.obj : error LNK2005: "void __cdecl xsignal_ready(struct xcondition_variable *)" (?xsignal_ready@@YAXPAUxcondition_variable@@@Z) already defined in main.obj
tobii.obj : error LNK2005: "void __cdecl report_and_exit_on_error(enum tobiigaze_error_code,char const *)" (?report_and_exit_on_error@@YAXW4tobiigaze_error_code@@PBD@Z) already defined in main.obj
moc_mainwindow.obj : error LNK2005: "void * __cdecl xthread_create(void *,void *)" (?xthread_create@@YAPAXPAX0@Z) already defined in main.obj
moc_mainwindow.obj : error LNK2005: "void __cdecl xthread_join(void *)" (?xthread_join@@YAXPAX@Z) already defined in main.obj
moc_mainwindow.obj : error LNK2005: "void __cdecl xinitialize_cv(struct xcondition_variable *)" (?xinitialize_cv@@YAXPAUxcondition_variable@@@Z) already defined in main.obj
moc_mainwindow.obj : error LNK2005: "int __cdecl xwait_until_ready(struct xcondition_variable *)" (?xwait_until_ready@@YAHPAUxcondition_variable@@@Z) already defined in main.obj
moc_mainwindow.obj : error LNK2005: "void __cdecl xsignal_ready(struct xcondition_variable *)" (?xsignal_ready@@YAXPAUxcondition_variable@@@Z) already defined in main.obj
moc_mainwindow.obj : error LNK2005: "void __cdecl report_and_exit_on_error(enum tobiigaze_error_code,char const *)" (?report_and_exit_on_error@@YAXW4tobiigaze_error_code@@PBD@Z) already defined in main.obj -
wrote on 29 Oct 2015, 22:53 last edited by
Hi, I think you're including the Tobii SDK file Common.h in every .cpp file in your project, that's why you get the errors. Try including it in only one .cpp file.
-
Hi, I think you're including the Tobii SDK file Common.h in every .cpp file in your project, that's why you get the errors. Try including it in only one .cpp file.
wrote on 30 Oct 2015, 08:08 last edited by@hskoglund
No, Im including it in only the tobii.h file. -
wrote on 30 Oct 2015, 09:11 last edited by
Ok, perhaps if you're instead including the tobii.h file in all your .cpp files the errors will also occur.
-
Ok, perhaps if you're instead including the tobii.h file in all your .cpp files the errors will also occur.
wrote on 31 Oct 2015, 22:06 last edited by@hskoglund
I include the tobii.h file in tobii.cpp and player.h file and thats all. -
wrote on 31 Oct 2015, 22:23 last edited by
Ok, the player.h file, are you including it from more than one .cpp file?
-
wrote on 1 Nov 2015, 13:36 last edited by
@hskoglund
The player.h file include in player.cpp and mainwindow.h. And the mainwindow.h include in mainwindow.cpp and main.cpp -
wrote on 1 Nov 2015, 21:57 last edited by
Ok, try removing the include of player.h in mainwindow.h. (This is what causes the errors it seems).
If you then get LNK2019 errors (unresolved external symbols) then you need to change the tobii.h file so it does not include the common.h file, we cross that bridge when we get to it :-)
-
wrote on 6 Nov 2015, 09:18 last edited by
Ok, I solved the problem. The problem was, that in the common.h file there were function definitions, so i separated it to .cpp and .h file.
Thanks all.
1/9