c - "Undefined symbol <function> first referenced in file <file>" link error -


i'm writing first program in c class; i've managed out of syntax errors, i'm getting strange error when gcc tries link object files together. prints below:

gcc -o proj04.support.o proj04.driver.o undefined                       first referenced  symbol                             in file convert                             proj04.driver.o 

i've looked around few answers, none make sense me. i'll post files i'm using make program below, , if you've got answer appreciate help. seems pretty basic error, it's silly didn't do.

makefile (posting first because suspect issue here)

# comments # comments  proj04: proj04.support.o proj04.driver.o         gcc -o proj04.support.o proj04.driver.o  proj04.support.o: proj04.support.c         gcc -wall -c proj04.support.c  proj04.driver.o: proj04.driver.c         gcc -wall -c proj04.driver.c 

header file (provided professor, unchangeable, 1 line long):

int convert( int, unsigned, char[], int ) 

implementation file

#include <stdio.h> #include "/user/cse320/projects/project04.support.h" #include <string.h>  void formatdisplay( char[], int );  int convert( int i, unsigned base, char result[], int display ) {   int quotient, dividend, remainder;   const int divisor = base;   int count = 0;   char ending[] = " base ";    dividend = i;   remainder = 0;   quotient = 1;    while (quotient != 0)   {     if (count <= strlen(result))     {       quotient = (dividend / divisor);       remainder = (dividend % divisor);       //convert ascii char       result[count] = remainder;       count++;     }   }    formatdisplay ( result, display );    strrev(result);    if ( >= 0 ) { result[0] = '+'; }   if ( < 0 ) { result[0] = '-'; }    printf( "%s" , strcat (result, ending));  }       void formatdisplay ( char str[], int disp ) {        if ( disp < 0 )   {     unsigned = 0;     ( i; < strlen(str)-1; i++)     {       if ( str[i] = '\0') { str[i] = '0'; }     }   }   if ( disp >= 0 )   {      unsigned = 0;     ( i; < strlen(str)-1; i++)     {        if ( str[i] = '\0') { str[i] = ' '; }     }   }    }  

driver file (not implemented yet)

#include <stdio.h> #include "/user/cse320/projects/project04.support.h"  int main () {   char result1[32];   int t = convert(10, 2, result1, 1); } 

yes, problem in makefile:

proj04: proj04.support.o proj04.driver.o         gcc -o proj04.support.o proj04.driver.o 

the -o option gcc takes argument, output filename. asking gcc link file proj04.driver.o, producing output file of proj04.support.o.

gcc -o proj04 proj04.support.o proj04.driver.o should work better.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -