Thread: Weird compile error "(.text+0x32): undefined reference to `cubeByReference'"

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    182

    Weird compile error "(.text+0x32): undefined reference to `cubeByReference'"

    I get this strange error compiling this program. I think there was a compiler parameter that fixed this but it's been years since I've used C. Does anyone know? I'm using Ubuntu Linux.

    Code:
    #include <stdio.h>
    
    void cybeByReference( int * );
    
    int main()
    {
    	int number = 5;
    
    	printf( "The original value of number is %d", number );
    	cubeByReference( &number );
    	printf( "\nThe new value of number is %d\n", number );
    
    	return 0;
    }
    
    
    void cybeByReference( int *nPtr )
    {
    	*nPtr = *nPtr * *nPtr * *nPtr;
    }


    Code:
    eugene@eugene-laptop:~/cfiles$ cc -Wall -pedantic fig07_07.c
    fig07_07.c: In function ‘main’:
    fig07_07.c:10: warning: implicit declaration of function ‘cubeByReference’
    /tmp/cck2bZ1N.o: In function `main':
    fig07_07.c:(.text+0x32): undefined reference to `cubeByReference'
    collect2: ld returned 1 exit status

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by yougene View Post
    I get this strange error compiling this program. I think there was a compiler parameter that fixed this but it's been years since I've used C. Does anyone know? I'm using Ubuntu Linux.

    Code:
    #include <stdio.h>
    
    void cybeByReference( int * );
    
    int main()
    {
    	int number = 5;
    
    	printf( "The original value of number is %d", number );
    	cubeByReference( &number );
    	printf( "\nThe new value of number is %d\n", number );
    
    	return 0;
    }
    
    
    void cybeByReference( int *nPtr )
    {
    	*nPtr = *nPtr * *nPtr * *nPtr;
    }


    Code:
    eugene@eugene-laptop:~/cfiles$ cc -Wall -pedantic fig07_07.c
    fig07_07.c: In function ‘main’:
    fig07_07.c:10: warning: implicit declaration of function ‘cubeByReference’
    /tmp/cck2bZ1N.o: In function `main':
    fig07_07.c:(.text+0x32): undefined reference to `cubeByReference'
    collect2: ld returned 1 exit status
    Surprisingly, there is no compiler parameter for "I can't spell".

  3. #3
    Registered User
    Join Date
    May 2006
    Posts
    182
    Good eye. But that didn't solve the error message.

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    I assumed you would change both the cybe's to cube's, so I didn't color them both in; but you did also misspell the function name down below.

  5. #5
    Registered User
    Join Date
    May 2006
    Posts
    182
    Ahh, you're right. Thanks

    There really is a special parameter I swear!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. In over my head
    By Shelnutt2 in forum C Programming
    Replies: 1
    Last Post: 07-08-2008, 06:54 PM
  2. Undefined Reference Compiling Error
    By AlakaAlaki in forum C++ Programming
    Replies: 1
    Last Post: 06-27-2008, 11:45 AM
  3. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  4. Question about OpenGL/Linux
    By Ideswa in forum Linux Programming
    Replies: 12
    Last Post: 09-10-2006, 05:56 AM
  5. qt help
    By Unregistered in forum Linux Programming
    Replies: 1
    Last Post: 04-20-2002, 09:51 AM