Qt app compile error.



  • 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



  • 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.



  • @hskoglund
    No, Im including it in only the tobii.h file.



  • Ok, perhaps if you're instead including the tobii.h file in all your .cpp files the errors will also occur.



  • @hskoglund
    I include the tobii.h file in tobii.cpp and player.h file and thats all.



  • Ok, the player.h file, are you including it from more than one .cpp file?



  • @hskoglund
    The player.h file include in player.cpp and mainwindow.h. And the mainwindow.h include in mainwindow.cpp and main.cpp



  • 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 :-)



  • 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.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.