Results 1 to 4 of 4

Thread: main.c:(.text+0x55): undefined reference to

  1. #1
    Join Date
    Aug 2008
    Beans
    543

    main.c:(.text+0x55): undefined reference to

    I'm getting this error. I'm guessing either there is an error in my code or I am missing a library. Can I please have some ideas on what the problem is?

    Code:
    main.c:(.text+0x55): undefined reference to
    Code:
    $ gcc *.c
    /tmp/ccP8MDTO.o: In function `getInput':
    main.c:(.text+0x55): undefined reference to `validateInput'
    main.c:(.text+0xb2): undefined reference to `validateInput'
    main.c:(.text+0x10f): undefined reference to `validateInput'
    collect2: ld returned 1 exit status
    Code:
    bool getInput (int* pFahrenheit, int* pFeet, int* pPounds)
    {
    	bool isValid=false;
    	//Prompt for Temperature
    	int count=scanf("%d",pFahrenheit);
    	if(count==1)
    	{
    		if (validateInput(*pFahrenheit,0,212))
    		{
    			isValid=true;
    		}
    	}
    }

  2. #2
    Join Date
    May 2007
    Location
    Leeds, UK
    Beans
    1,664
    Distro
    Ubuntu 13.10 Saucy Salamander

    Re: main.c:(.text+0x55): undefined reference to

    You are using a function called validateInput but the compiler can't find the declaration of it.

    Could you show your complete source file?
    Please create new threads for new questions.
    Please wrap code in code tags using the '#' button or enter it in your post like this: [code]...[/code].

  3. #3
    Join Date
    Apr 2012
    Beans
    5,063

    Re: main.c:(.text+0x55): undefined reference to

    ... the linker can't find the definition of it, surely?

    My guess is that your getInput and validateInput functions are defined in separate local source files that are part of your *.c glob - but the order in which the shell expands *.c is not necessarily the order in which the linker needs to resolve the modules. But like r-senior says, we need to see more of the code.

  4. #4
    Join Date
    May 2007
    Location
    Leeds, UK
    Beans
    1,664
    Distro
    Ubuntu 13.10 Saucy Salamander

    Re: main.c:(.text+0x55): undefined reference to

    Yes, my terminology was sloppy.
    Please create new threads for new questions.
    Please wrap code in code tags using the '#' button or enter it in your post like this: [code]...[/code].

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •