Find the answer to your Linux question:
Results 1 to 6 of 6
Hi guys, ive got a problem, im a first year computer sciences student and im just goin over work at home and im getting this error, Code: prog3.c:(.text+0x16): undefined reference ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Feb 2010
    Posts
    2

    C noob.


    Hi guys,

    ive got a problem, im a first year computer sciences student and im just goin over work at home and im getting this error,
    Code:
    prog3.c:(.text+0x16): undefined reference to `getInt'
    prog3.c:(.text+0x2b): undefined reference to `getInt'
    prog3.c:(.text+0x40): undefined reference to `getInt'
    prog3.c:(.text+0x55): undefined reference to `getChar'
    prog3.c:(.text+0x6a): undefined reference to `getChar'
    the code is,

    Code:
    #include <stdio.h>
    
    int main()
    {
    	int a, b, c; 
     	char d, e;
    
    	printf("Please input a value \n"); a = getInt();
    	printf("Please input a value \n"); b = getInt();
    	printf("Please input a value \n"); c = getInt();
    	printf("Please input a Char \n"); d = getChar();
    	printf("Please input a Char \n"); e = getChar();
    
    	printf("Equality example:\n");
    	printf("\tIs a equal to b? (0==0) %d (true) \n", a==b );
    	printf("\tIs d equal to e? (A==a) %d (false)\n", d==e );
    	printf("Inequality example:\n\tIs a not equal to c? ");
    	printf(" (0!=1) %d (true)\n", a != c );
    	printf("Greater than example:\n\tIs a greater than c?");
    	printf("(0>1) %d (false) \n", a > c ) ;
    	printf("Less than example:\n\tIs a less than c?");
    	printf(" (0<1) %d (true) \n", a < c );
    	printf("Greater than or equal to example:\n");
    	printf("\tIs a greater than or equal to be? ");
    	printf(" (0>=0) %d (true) \n", a >= b );
    	printf("Less than or equal to example:\n");
    	printf("\tIs c less than or equal to a? ");
    	printf("(1<=0 %d (false) \n", c <= a );
    
    	return 0;
    }

    i really am a noob so any advice would be apreciated.

    cheers =)

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,753
    Where is the functions getInt() and getChar() declared & defined?
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  3. #3
    Just Joined!
    Join Date
    Feb 2010
    Posts
    2
    hmm we use simpleio.h at uni but i havent got it on my home computer, would this be why?

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Guru coopstah13's Avatar
    Join Date
    Nov 2007
    Location
    NH, USA
    Posts
    3,149
    most likely, if that is where those functions are defined you need to include that header to use it, you should be able to copy the file to a flash drive on a uni computer and bring it home though

  6. #5
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,753
    Quote Originally Posted by coopstah13 View Post
    most likely, if that is where those functions are defined you need to include that header to use it, you should be able to copy the file to a flash drive on a uni computer and bring it home though
    Yes. You need the header as well as the library (either shared or static) that contains the implementation of these functions. Also, if the platforms are incompatible (your system and school's), then you will need the source code of that library to compile on your system, or a copy that is compatible with your system.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  7. #6
    Just Joined!
    Join Date
    Feb 2010
    Posts
    2
    Quote Originally Posted by bulleh View Post
    Hi guys,

    ive got a problem, im a first year computer sciences student and im just goin over work at home and im getting this error,
    Code:
    prog3.c:(.text+0x16): undefined reference to `getInt'
    prog3.c:(.text+0x2b): undefined reference to `getInt'
    prog3.c:(.text+0x40): undefined reference to `getInt'
    prog3.c:(.text+0x55): undefined reference to `getChar'
    prog3.c:(.text+0x6a): undefined reference to `getChar'
    the code is,

    Code:
    #include <stdio.h>
    
    int main()
    {
    	int a, b, c; 
     	char d, e;
    
    	printf("Please input a value \n"); a = getInt();
    	printf("Please input a value \n"); b = getInt();
    	printf("Please input a value \n"); c = getInt();
    	printf("Please input a Char \n"); d = getChar();
    	printf("Please input a Char \n"); e = getChar();
    
    	printf("Equality example:\n");
    	printf("\tIs a equal to b? (0==0) %d (true) \n", a==b );
    	printf("\tIs d equal to e? (A==a) %d (false)\n", d==e );
    	printf("Inequality example:\n\tIs a not equal to c? ");
    	printf(" (0!=1) %d (true)\n", a != c );
    	printf("Greater than example:\n\tIs a greater than c?");
    	printf("(0>1) %d (false) \n", a > c ) ;
    	printf("Less than example:\n\tIs a less than c?");
    	printf(" (0<1) %d (true) \n", a < c );
    	printf("Greater than or equal to example:\n");
    	printf("\tIs a greater than or equal to be? ");
    	printf(" (0>=0) %d (true) \n", a >= b );
    	printf("Less than or equal to example:\n");
    	printf("\tIs c less than or equal to a? ");
    	printf("(1<=0 %d (false) \n", c <= a );
    
    	return 0;
    }

    i really am a noob so any advice would be apreciated.

    cheers =)
    Find out in which header file , getInt() and getChar() functions are defined and add that header in your .c file. The problem will be solved.

Posting Permissions

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