Why show the this error message "undefined reference to function error". ?



  • Hello
    I've some problem on my qt program.

    problem :

    I want to use myfunc(unsigned char Param1, unsigned char Param2) function in myClass.
    This function's location is in another folder.
    so, I include the function location path in myClass header file.

    but, when I build the source, the error message is show like this. "undefined reference to 'myfunc(unsigned char, unsigned char)'

    I saw the many kind of solution on google web site, but it still not solve this problem..

    Is anybody know the this problem? Why does the problem occur?


  • Moderators

    Hi!
    Where is the definition of this function?
    Usually a header file only contains a declaration like this:

    void myfunc(unsigned char Param1, unsigned char Param2);
    

    And then the definition is in a cpp file:

    void myfunc(unsigned char Param1, unsigned char Param2)
    {
    
    }
    

    The error message you get says that the definition of that function was not found. You probably forgot to add the cpp file to your project or you do not have the definition at all (its difficult to say as you did not provide enough information).



  • @jsulm

    Hi! jsulm.

    Thank you for give solution to me.
    I'm not good at use the qt Creator, so I forgot to add the cpp file in my project.

    This is simple errors right?

    anyway i solved my problem, because of you. thanks.


Log in to reply
 

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