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 Update on Monday, May 27th 2025

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.
  • E Offline
    E Offline
    Eng.Jason
    wrote on 11 May 2016, 02:47 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
    • J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 11 May 2016, 04:20 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

      E 1 Reply Last reply 11 May 2016, 05:01
      0
      • J jsulm
        11 May 2016, 04:20

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

        E Offline
        E Offline
        Eng.Jason
        wrote on 11 May 2016, 05:01 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

        3/3

        11 May 2016, 05:01

        • Login

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