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 7807211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:46:57+00:00 2026-06-02T02:46:57+00:00

I don’t know why I am getting this linking error, I am pretty sure

  • 0

I don’t know why I am getting this linking error, I am pretty sure everything is linked correctly

gcc -Wall -Wextra -o test driver.c target.c 
driver.c:8: warning: unused parameter ‘argc’
ld: duplicate symbol _first in /var/folders/yx/31ddgzsj4k97jzvwhfx7tkz00000gn/T//ccw2n48G.o and /var/folders/yx/31ddgzsj4k97jzvwhfx7tkz00000gn/T//ccKZdUlG.o for architecture x86_64
collect2: ld returned 1 exit status

I have the following code, which is a simple linked list, but I don’t know why it wont compile

driver.c

 #include "target.h"
 #include <stdio.h>
 #include <stdlib.h>

char * prog;
int main(int argc, char * argv[]){
  prog = argv[0];
  print_target_list(1);
  .....

target.c

#include "target.h"
/* This function returns true if there is a target with name in the target linked list */
bool is_target(char * name){
    struct target_node * ptr = first;
   while(ptr != NULL){
    if(strcmp(ptr->name,name) == 0){
      return true;
    }
    ptr = ptr->next;
  }
  return false;
}
......

target.h

#ifndef TARGET_H
#define TARGET_H

//#include "source.h"
#include <stdbool.h>
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>

/*-----------------------------------------*/

extern char * prog;

/*-----------------------------------------*/

struct source_node{
  char * name;
};

struct target_node{
  char * name;
  struct target_node * next;
  struct source_node * src_node;
};

struct target_node * first = NULL;

/*-----------------------------------------------------*/


/* return 1 if name is in the target linked list 0 otherwise */
bool is_target(char * name);
/* returns a new target_node */ 
struct target_node * new_target_node(char * name);
/* insert a new target_node into the list */
void insert_target_node(char * name);
/* remove a target_node from the list */
void remove_target_node(char * name);
/* print the current linked list */
void print_target_list(int opts);


#endif

Any help would be appricated

  • 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-02T02:46:58+00:00Added an answer on June 2, 2026 at 2:46 am

    In target.h use:

    extern struct target_node * first;
    

    And place the following in the appropriate target.c file:

    struct target_node * first = NULL;
    

    If first isn’t needed outside of target.c, it can be removed from target.h altogether (and maybe made static in target.c if you want to avoid putting it in the global namespace needlessly).

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

Sidebar

Related Questions

Don't know what to do with this error. How to add data in SQL
Don't know why this conversion fails. SELECT CAST('32.999' AS INT) throws the error saying
don't know better title for this, but here's my code. I have class user
Don't dismiss this as a newbie question! It's not, I'm not, I've tried everything,
Don't really know how to formulate the title, but it should be pretty obvious
(Don't know if this is strictly on-topic, but I don't see any better Stack
Don't know if this has been asked before, so point me to another question
Don't know if anyone can help me with this or if it's even possible.
I don't know: if this works. if it's a good idea. what it is
I don't know if this question is trivial or not. But after a couple

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.