0

Alright, I'm trying to call a function in xcode but apparently it isn't working. I made an objective-c class, and typed in the following code into the implementation file:

#import "Person.h"

@implementation Person

void printthis()
{
    NSLog(@"Hi, I have been printed");
}

int main(int argc, const char * argv[])
{

    @autoreleasepool {

        printthis();

    }
    return 0;
}



@end

Apparently, it returns the following error in xcode:

    ld: 1 duplicate symbol for architecture x86_64
clang: error:
    linker command failed with exit code 1 (use -v to see invocation)

1 Answer 1

2

Did you already have a main function somewhere else (probably main.m ?). If so the linker got confused -- you are not supposed to have duplicates of main function

Sign up to request clarification or add additional context in comments.

1 Comment

Actually thanks, I had a main.m file with the main function as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.