Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8162037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:37:27+00:00 2026-06-06T18:37:27+00:00

Here are my 2 source files: main.c: #include <stdio.h> #include part2.c extern int var1;

  • 0

Here are my 2 source files:

main.c:

#include <stdio.h>
#include "part2.c"

extern int var1;
extern int array1[];

int main()
{
    var1 = 4;
    array1[0] = 2;
    array1[1] = 4;
    array1[2] = 5;
    array1[3] = 7;

    display();

    printf("---------------");

    printf("Var1: %d", var1);
    printf("array elements:");

    int x;
    for(x = 0;x < 4;++x)
        printf("%d: %d", x, array1[x]);

    return 0;
}

part2.c

#include <stdio.h>

int var1;
int array1[4];

void display(void);

void display(void)
{
    printf("Var1: %d", var1);
    printf("array elements:");

    int x;
    for(x = 0;x < 4;++x)
        printf("%d: %d", x, array1[x]);
}

When i try to compile the program this is what i get:

Ld /Users/John/Library/Developer/Xcode/DerivedData/Test-blxrdmnozbbrbwhcekmouessaprf/Build/Products/Debug/Test normal x86_64
cd /Users/John/Xcode/Test
setenv MACOSX_DEPLOYMENT_TARGET 10.7
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk -L/Users/John/Library/Developer/Xcode/DerivedData/Test-blxrdmnozbbrbwhcekmouessaprf/Build/Products/Debug -F/Users/John/Library/Developer/Xcode/DerivedData/Test-blxrdmnozbbrbwhcekmouessaprf/Build/Products/Debug -filelist /Users/John/Library/Developer/Xcode/DerivedData/Test-blxrdmnozbbrbwhcekmouessaprf/Build/Intermediates/Test.build/Debug/Test.build/Objects-normal/x86_64/Test.LinkFileList -mmacosx-version-min=10.7 -o /Users/John/Library/Developer/Xcode/DerivedData/Test-blxrdmnozbbrbwhcekmouessaprf/Build/Products/Debug/Test

ld: duplicate symbol _display in /Users/John/Library/Developer/Xcode/DerivedData/Test-blxrdmnozbbrbwhcekmouessaprf/Build/Intermediates/Test.build/Debug/Test.build/Objects-normal/x86_64/part2.o and /Users/John/Library/Developer/Xcode/DerivedData/Test-blxrdmnozbbrbwhcekmouessaprf/Build/Intermediates/Test.build/Debug/Test.build/Objects-normal/x86_64/main.o for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I am using Xcode and both files are inside of a C project called Test

What is causing the error and how do i fix it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T18:37:27+00:00Added an answer on June 6, 2026 at 6:37 pm

    Remove “#include "part2.c"” and change it to “#include "part2.h“

    And move your function declaration of:

    void display(void);
    

    from the top of your “part.c” file into a file named “part2.h“, which should be included in (or put at the top of) both .c files.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey all. I've downloaded and moved the Xerces (v3.1.1) source here: /usr/include/xerces and I
Referring here A is a precompiled Java class (I also have the source file)
Here is the source xml: xml This is the xml of an fxg file
I'm trying to perform a skew on an image, like one shown here (source:
Here is source code: @OneToOne(fetch = FetchType.LAZY) @Cascade({SAVE_UPDATE, EVICT, DELETE}) @JoinColumn(name = A_ID, nullable
Edit: You can get the full source here: http://pastebin.com/m26693 Edit again: I added some
To see what I mean, check out my source here in IE. When you
var _thumb = $('.galleria img[@rel='+_src+']'); Full source here Is it a deprecated selector?
I have downloaded pdcurses source and was able to successfully include curses.h in my
I have a dirty working tree, dirty because I made changes to source files

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.