• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
A novice question.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

A novice question.


  • Subject: A novice question.
  • From: Michael <email@hidden>
  • Date: Tue, 4 Dec 2007 17:40:52 -0800

I am doing a very simple program using the standard tool to learn about linking different files. I get an error: below



The code is in 3 files. 

Main.c

#include <stdio.h>
#include "header.h"
#include "utilities.c"

int main (int argc, const char * argv[]) {
    // insert code here...
    printf("Hello, World!\n");
    return 0;
}


header.h

/*
 *  header.h
 *  functionstoptrs
 *
 *  Created by PB_G4 on 12/4/07.
 *  Copyright 2007 __MyCompanyName__. All rights reserved.
 *
 */

int mystrcmp( char *, char *);

utilities.c

/*
 *  utilities.c
 *  functionstoptrs
 *
 *  Created by PB_G4 on 12/4/07.
 *  Copyright 2007 __MyCompanyName__. All rights reserved.
 *
 */

#include "header.h"

int mystrcmp( char *s, char *t){
for ( ; *s == *t; s++, t++)
if( *s== '\0')
return 0;
return ( ( *s > *t) - ( *t > *s) );
}

The error message is a follows.



Building target “functionstoptrs” of project “functionstoptrs” with configuration “Release” — (1 error)
    cd "/..../functionstoptrs"
    /Developer/usr/bin/gcc-4.0 -o /..../functionstoptrs/build/functionstoptrs.build/Release/functionstoptrs.build/Objects-normal/ppc/functionstoptrs -L
/......./functionstoptrs/build/Release -F/......./functionstoptrs/build/Release -filelist /......./functionstoptrs/build/functionstoptrs.build/Release/functionstoptrs.build/Objects-normal/ppc/functionstoptrs.LinkFileList -arch ppc -mmacosx-version-min=10.5 -isysroot /Developer/SDKs/MacOSX10.5.sdk
ld: duplicate symbol _mystrcmp in /........../functionstoptrs/build/functionstoptrs.build/Release/functionstoptrs.build/Objects-normal/ppc/utilities.o and /........../functionstoptrs/build/functionstoptrs.build/Release/functionstoptrs.build/Objects-normal/ppc/main.o

collect2: ld returned 1 exit status
ld: duplicate symbol _mystrcmp in /........../functionstoptrs/build/functionstoptrs.build/Release/functionstoptrs.build/Objects-normal/ppc/utilities.o and /Users/m/k&R/functionstoptrs/build/functionstoptrs.build/Release/functionstoptrs.build/Objects-normal/ppc/main.o
collect2: ld returned 1 exit status
Build failed (1 error)


I understand that the compiler believes mystrcmp is being duplicated, but I am not sure I understand why this is happening.
Could someone help me become unstuck? 


thank you in advance.








 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: A novice question.
      • From: A.M. <email@hidden>
    • Re: A novice question.
      • From: Dave Hersey <email@hidden>
  • Prev by Date: creating a new class and instance
  • Next by Date: Re: Plist not being updated
  • Previous by thread: Re: creating a new class and instance
  • Next by thread: Re: A novice question.
  • Index(es):
    • Date
    • Thread