Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Why show the this error message "undefined reference to function error". ?
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 862 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Eng.JasonE Offline
    Eng.JasonE Offline
    Eng.Jason
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

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

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      Eng.JasonE 1 Reply Last reply
      0
      • jsulmJ jsulm

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

        Eng.JasonE Offline
        Eng.JasonE Offline
        Eng.Jason
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved