Skip to main content



      Home
Home » Newcomers » Newcomers » multiple definition error(get multiple definition SECOND time I compile)
icon11.gif  multiple definition error [message #1243351] Mon, 10 February 2014 17:03 Go to next message
Eclipse UserFriend
Hi,

I get an error:
./src/application/uwbFcns.o: In function `.LANCHOR1':
uwbFcns.c:(.rodata+0x60): multiple definition of `rfDelays'
./src/application/main.o:main.c:(.rodata+0xc): first defined here
./src/application/uwbFcns.o: In function `.LANCHOR1':
uwbFcns.c:(.rodata+0x0): multiple definition of `tx_SpectrumConfig'
./src/application/main.o:main.c:(.rodata+0x10): first defined here
collect2.exe: error: ld returned 1 exit status
cs-make: *** [ARMUWB.elf] Error 1

IF I search my project, I see that the variables are only defined in one header file. If I change the name of each variable (just add an underscore in the middle) the project compiles fine. Until I ma a change and compile again. Then I get the same error all over again. I can change the names again (remove the underscores) but the same thing happens (compiles fine first time, then not the second).

Help!

Thanks!

John
Re: multiple definition error [message #1243472 is a reply to message #1243351] Mon, 10 February 2014 21:41 Go to previous messageGo to next message
Eclipse UserFriend
On 2/10/2014 4:57 PM, John Madsen wrote:
> Hi,
>
> I get an error:
> /src/application/uwbFcns.o: In function `.LANCHOR1':
> uwbFcns.c:(.rodata+0x60): multiple definition of `rfDelays'
> /src/application/main.o:main.c:(.rodata+0xc): first defined here
> /src/application/uwbFcns.o: In function `.LANCHOR1':
> uwbFcns.c:(.rodata+0x0): multiple definition of `tx_SpectrumConfig'
> /src/application/main.o:main.c:(.rodata+0x10): first defined here
> collect2.exe: error: ld returned 1 exit status
> cs-make: *** [ARMUWB.elf] Error 1
>
> IF I search my project, I see that the variables are only defined in one
> header file. If I change the name of each variable (just add an
> underscore in the middle) the project compiles fine. Until I ma a
> change and compile again. Then I get the same error all over again. I
> can change the names again (remove the underscores) but the same thing
> happens (compiles fine first time, then not the second).
>
> Help!
>
> Thanks!
>
> John
My guess would be that you are including the header file in multiple .c
files. If you don't have some conditional compilation statements that
surround the definitions, the variables will get defined in each .c file
they are included in.

Note that this is really a C/C++ programming question. General
programming questions like this aren't appropriate for the Eclipse
forums. They are for questions about Eclipse tools.
Re: multiple definition error [message #1245964 is a reply to message #1243472] Fri, 14 February 2014 09:29 Go to previous messageGo to next message
Eclipse UserFriend
Thank you for your reply. The header was referenced in two different .c files, but the conditional compilation statements WERE there (nothing else in that header caused the error). I believe the problem was the way eclipse is not smart enough to recompile all files that are dependent on one that is changed, eg, if I make a change in a header file and hit the build button, it does not rebuild anything. I have to make a change in all files that use that header to get them to recompile.
Re: multiple definition error [message #1247007 is a reply to message #1245964] Sat, 15 February 2014 13:48 Go to previous message
Eclipse UserFriend
On 02/14/2014 07:29 AM, John Madsen wrote:
> Thank you for your reply. The header was referenced in two different .c
> files, but the conditional compilation statements WERE there (nothing
> else in that header caused the error). I believe the problem was the
> way eclipse is not smart enough to recompile all files that are
> dependent on one that is changed, eg, if I make a change in a header
> file and hit the build button, it does not rebuild anything. I have to
> make a change in all files that use that header to get them to recompile.

If you believe that's true, you might want to parley with the Eclipse
CDT crowd, a gathering of those who code in C/C++ and a better place to
ask such questions than here.
Previous Topic:Try-with-Resources
Next Topic:Compiling two separated source files with Fortran
Goto Forum:
  


Current Time: Sat Jul 19 19:55:59 EDT 2025

Powered by FUDForum. Page generated in 0.08063 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top