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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:53:50+00:00 2026-06-17T17:53:50+00:00

I have been given an already working Makefile which is actually working fine. Makefile

  • 0

I have been given an already working Makefile which is actually working fine.

Makefile Contents can be found here in this post …

Questions about Makefile – what is "$+" & where are .c files/dependencies called here ?

I am asking this question separately from my previous post mentioned above as it involves a different issue and adding it to that question would unnecessarily increase its length.

Now I have added one more functionality which is being used quite frequently at many places so I thought creating a separate file would be a nice idea so I created linklayer.c and added linklayer.o to $LIBOBJS.

I added this …

 LIBOBJS= linklayer.o csum.o compact.o protoname.o headers.o 
 parseargs.o cryptomod.o crc32.o

and this

 linklayer.o:    linklayer.c
    $(CC) -o $@ -c -I. $(CFLAGS) $+

I have declared function in sendip_module.h which is already declared and accessed in each of the module present in the project.

But now this multiple definition error is coming … Have I done something wrong or misunderstood something?

Note: “ipv6_opts” is defined in ipv6.h

$ make all
for subdir in mec ; do \
    cd $subdir ;\
    make  ;\
    cd ..  ;\
    done
make[1]: Entering directory `/home/udit/Desktop/sendip-2.5-mec-2/mec'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/udit/Desktop/sendip-2.5-mec-2/mec'
  gcc-4.4 -o ipv6.so -fPIC -fsigned-char -pipe -Wall -Wpointer-arith 
 -Wwrite-strings -Wstrict-prototypes -Wnested-externs -Winline -Werror
 -g -Wcast-align -DSENDIP_LIBS=\"/usr/local/lib/sendip\" -shared ipv6.c
  libsendipaux.a libsendipaux.a

 libsendipaux.a(linklayer.o):(.data.rel.local+0x0)
                              : multiple definition of `ipv6_opts'
 /tmp/ccxa4tMX.o:(.data.rel.local+0x0): first defined here
 collect2: ld returned 1 exit status
 make: *** [ipv6.so] Error 1

and why this libsendipaux.a libsendipaux.a two times ? Is there something wrong with the Makefile itself.

Do I first need to manually compile it and then add it to libsendipaux.a ?

I am new to this Makefile stuff, so please help me understand how this is all working out here ?

Thanks.

Edit :

Remake debugging output –

 remake -x

Reading makefiles...
Updating goal targets....
/home/udit/Desktop/sendip-2.5-mec-2/Makefile:33 File `all' does not exist.
/home/udit/Desktop/sendip-2.5-mec-2/Makefile:48 File `subdirs' does not exist.
/home/udit/Desktop/sendip-2.5-mec-2/Makefile:48 Must remake target `subdirs'.
for subdir in mec ; do \
    cd $subdir ;\
    make  ;\
    cd ..  ;\
    done
make[1]: Entering directory `/home/udit/Desktop/sendip-2.5-mec-2/mec'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/udit/Desktop/sendip-2.5-mec-2/mec'
/home/udit/Desktop/sendip-2.5-mec-2/Makefile:48 Successfully remade target file    
`subdirs'.
File `ipv6.so' does not exist.
Must remake target `ipv6.so'.
gcc-4.4 -o ipv6.so -fPIC -fsigned-char -pipe -Wall -Wpointer-arith 
-Wwrite-strings -Wstrict-prototypes -Wnested-externs -Winline -Werror 
-g -Wcast-align -DSENDIP_LIBS=\"/usr/local/lib/sendip\" -shared ipv6.c 
 libsendipaux.a libsendipaux.a
 libsendipaux.a(linklayer.o):(.data.rel.local+0x0)
                                  : multiple definition of `ipv6_opts'
 /tmp/ccb0oaXR.o:(.data.rel.local+0x0): first defined here
 collect2: ld returned 1 exit status
 remake: *** [ipv6.so] Error 1

 #0  ipv6.so at ??
 #1  all at /home/udit/Desktop/sendip-2.5-mec-2/Makefile:33

33rd line -> all: $(LIBS) subdirs sendip $(PROTOS) sendip.1 sendip.spec

I guess it could not help me out …. actual problem is with my understanding of scenario itself. Please help me bring out of the mess.

  • 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-17T17:53:51+00:00Added an answer on June 17, 2026 at 5:53 pm

    the problem you are facing, is that you are linking together several objects where at least two of them define de function ipv6_opts.
    since there are two implementations of the function, your linker cannot decide which one to use and throws an error.

    the problem most likely comes from the fact that you are linking libsendipaux.a twice into your final binary.

    the reason why this happens is here:

     %.so: %.c $(LIBS)
            $(CC) -o $@ $(CFLAGS) $(LIBCFLAGS) $+ $(LIBS)
    

    in this target, $+ will expand to all the dependencies of your target (that is: %.c $(LIBS), which will in turn be resolved to ipv4.c libsendipaux.a

    the actual call to the compiler can then be read as $(CC) -o $@ $(CFLAGS) $(LIBCFLAGS) ipv4.c $(LIBS) $(LIBS), and $(LIBS) $(LIBS) will expand to libsendipaux.a libsendipaux.a, which will produce the erroneous double linkeage.

    so the solution is to remove extraneous $(LIBS) from the .so target:

     %.so: %.c $(LIBS)
            $(CC) -o $@ $(CFLAGS) $(LIBCFLAGS) $+
    

    btw, the errors you get in remake about non-existing files, are because all and subdirs are indeed no files, but phony targets (targets that do no generate files called after the target-name).

    to prevent those warnings, add something like the following to your makefile:

    .PHONY: all subdirs
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been working on this project for my job, which involves backing up
this question feels like it would have been asked already, but I've not found
We have been given a site xyz.com, in which the home page has images
I have been working on this plugin system. I thought I passed design and
I am working on a Spring MVC application in which I have recently been
this kinda weird, i have been working on LAMP and suddenly realized that my
I have been given control of a web site in Classic ASP. What is
I have been given some poorly formatted data and need to pull numbers out
I have been given an exercise to solve the zebra puzzle using a constraint
I have been given the below .NET question in an interview. I don’t know

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.