MOD54415 compiler error messages

for everything else
jediengineer
Posts: 192
Joined: Mon Dec 17, 2012 6:24 am

MOD54415 compiler error messages

Post by jediengineer »

Hi Guys - I'm receiving an unfamiliar compiler message from eclipse... Be a little patient with me if this seems too simple - I'm still new to embedded development with C and C++, and haven't done this in 15 years. Sorry, I'm not allowed to post code per customer's request.

The messages are this:

funcs.od:(.data+0x0): multiple definition of `ADC'
startup.od:(.data+0x0): first defined here
funcs.od:(.data+0x20): multiple definition of `MUX_POS'
startup.od:(.data+0x20): first defined here
87-764-2800rev1.od:(.data+0x0): multiple definition of `ADC'
startup.od:(.data+0x0): first defined here
87-764-2800rev1.od:(.data+0x20): multiple definition of `MUX_POS'
startup.od:(.data+0x20): first defined here

I'm not sure what the ".od" files are, or how to address the propblem. When I double click the error, it opens the file, but all I have is ascii characters (funny ones, not the text) that I can't decipher... can someone shed a little light? Thanks!
User avatar
dciliske
Posts: 623
Joined: Mon Feb 06, 2012 9:37 am
Location: San Diego, CA
Contact:

Re: MOD54415 compiler error messages

Post by dciliske »

So, first of all, '.od' files are "object, debug" files. These are the compiled source for (presumably) your project before everything gets smashed together to form the application image/executable. If you were building the release mode of your project you'd get '.o' files instead.

Multiple definition errors is the compiler basically yelling at you saying it doesn't know what version of a symbol (variable or function) to use because it's found multiple ones (normally when it's linking the executable together from the individual object files).

Now, based on the messages here, you've got a couple variables that get defined twice, which you <sarcasm>obviously</sarcasm> shouldn't be doing. My guess is that the variables are listed in a header file without declaring them 'extern'. This will attempt to instantiate the variable in every file that includes the header. The right way to do this is to have the variable 'extern' in the header, but declared in one file, so it actually gets allocated. It's also possible that you've got a backed up file in your project that is getting included in the output, which is screwing things up (87-764-2800rev1.cpp doesn't sound like a normal filename...).

-Dan
Dan Ciliske
Project Engineer
Netburner, Inc
jediengineer
Posts: 192
Joined: Mon Dec 17, 2012 6:24 am

Re: MOD54415 compiler error messages

Post by jediengineer »

Thanks Dan, I'll look closer at my header files. I didn't understand the .od file... I had figured it would find the error in the .cpp files. I did move all my defines to a header file, and originally I did have some duplicates. I thought I got rid of all of them. 87-764-2800rev1.cpp is actually the correct file name. It's a "part number" for the software so to speak, and will most likely change before I'm through. But for now, that's just how they want me to label it. I'll go through my files and see if there are multiple definitions again, but these listed were the original ones I fixed already (I'm pretty sure at least).
User avatar
tod
Posts: 587
Joined: Sat Apr 26, 2008 8:27 am
Location: Southern California
Contact:

Re: MOD54415 compiler error messages

Post by tod »

This may seem somewhat pedantic but...
What you are seeing are "linker" errors, not compiler errors. The compiler actually compiled your code with no problem. The linker however wasn't happy. The reason I mention this is to clarify why you're seeing the object files (.o or .od) not the source files, in the error message. Since the linker links together the object files that is what it reports as the problem. The GNU tool chain muddies up this distinction somewhat as the gcc and g++ tools that you see invoked are a higher level beast, in effect a "driver" tool that invokes the needed tools in the preprocessor/compiler/linker chain. For example, in the console window, you will see at the start some lines that look something like: m68k-elf-g++ ... That command gets used for compiling and for linking.

Later (once you link successfully), you will also see additional tools like m68k-elf-objcopy and compcode that are more embedded and NetBurner (respectively) specific.

Also you do have include guards (or #pragma once) on all your header files right?
jediengineer
Posts: 192
Joined: Mon Dec 17, 2012 6:24 am

Re: MOD54415 compiler error messages

Post by jediengineer »

Tod, I do not have include guards... not sure how they're used...

If you're referring to:


#ifndef DEFS_H_
#define DEFS_H_

// header info


#endif /* DEFS_H_ */

Then yes, I have those included.
jediengineer
Posts: 192
Joined: Mon Dec 17, 2012 6:24 am

Re: MOD54415 compiler error messages

Post by jediengineer »

Currently this is the entire error message I'm receiving:

**** Build of configuration Debug for project 87-764-2800rev1 ****

**** Internal Builder is used for build ****
m68k-elf-g++ -O0 -falign-functions=4 -D_DEBUG -IC:\nburn/include -IC:\nburn/MOD5441X/include -IC:\nburn/gcc-m68k/m68k-elf/include -IX:\NRG\87-764-2800rev1 -gdwarf-2 -Wall -Wno-write-strings -c -fmessage-length=0 -fno-rtti -fno-exceptions -mcpu=5206e -DMOD5441X -DMCF5441X -o funcs.od ..\funcs.cpp
m68k-elf-g++ -O0 -falign-functions=4 -D_DEBUG -IC:\nburn/include -IC:\nburn/MOD5441X/include -IC:\nburn/gcc-m68k/m68k-elf/include -IX:\NRG\87-764-2800rev1 -gdwarf-2 -Wall -Wno-write-strings -c -fmessage-length=0 -fno-rtti -fno-exceptions -mcpu=5206e -DMOD5441X -DMCF5441X -o startup.od ..\startup.cpp
m68k-elf-g++ -O0 -falign-functions=4 -D_DEBUG -IC:\nburn/include -IC:\nburn/MOD5441X/include -IC:\nburn/gcc-m68k/m68k-elf/include -IX:\NRG\87-764-2800rev1 -gdwarf-2 -Wall -Wno-write-strings -c -fmessage-length=0 -fno-rtti -fno-exceptions -mcpu=5206e -DMOD5441X -DMCF5441X -o 87-764-2800rev1.od ..\87-764-2800rev1.cpp
m68k-elf-g++ startup.od funcs.od 87-764-2800rev1.od -Wl,-Map=87-764-2800rev1.map -mcpu=5206e -Wl -Wl,-n -TC:\nburn/MOD5441X/lib/MOD5441X.ld -Wl,-RC:\nburn/MOD5441X/lib/sys.ld -Wl,--start-group,C:\nburn/lib/DBMOD5441X.a C:\nburn/lib/DBNetBurner.a C:\nburn/lib/FatFile.a C:\nburn\lib\DBdebugLibrary.a C:\nburn\lib\DBLua_Full.a -Wl,--end-group -o87-764-2800rev1.elf
funcs.od:(.data+0x0): multiple definition of `ADC'
startup.od:(.data+0x0): first defined here
funcs.od:(.data+0x20): multiple definition of `MUX_POS'
startup.od:(.data+0x20): first defined here
87-764-2800rev1.od:(.data+0x0): multiple definition of `ADC'
startup.od:(.data+0x0): first defined here
87-764-2800rev1.od:(.data+0x20): multiple definition of `MUX_POS'
startup.od:(.data+0x20): first defined here
collect2: ld returned 1 exit status
Build error occurred, build is stopped
Time consumed: 1160 ms.
User avatar
dciliske
Posts: 623
Joined: Mon Feb 06, 2012 9:37 am
Location: San Diego, CA
Contact:

Re: MOD54415 compiler error messages

Post by dciliske »

Ok, real quick, can you list every location where the variables ADC and MUX_POS are defined i.e.
In header file 'blahblah.h', line xyz,

Code: Select all

uint8_t ADC;
And if the things are in a header file, tell us what includes those headers.

Also, Tod's entirely correct on things, I just didn't want to get bogged down in the details that I didn't think were hugely relevant at the time (entirely subjective decision).

-Dan
Dan Ciliske
Project Engineer
Netburner, Inc
jediengineer
Posts: 192
Joined: Mon Dec 17, 2012 6:24 am

Re: MOD54415 compiler error messages

Post by jediengineer »

They are listed in a header file called "defs.h" as such:

// ADC input addresses:
WORD ADC[16] = { 0xADC0, 0xADC1, 0xADC2, 0xADC3, 0xADC4, 0xADC5, 0xADC6, 0xADC7, 0xADC8, 0xADC9, 0xADCA, 0xADCB, 0xADCC, 0xADCD, 0xADCE, 0xADCF };

// Mux position addresses:
WORD MUX_POS[32] = { 0xD100, 0xD101, 0xD102, 0xD103, 0xD104, 0xD105, 0xD106, 0xD107, 0xD108, 0xD109, 0xD10A, 0xD10B, 0xD10C, 0xD10D, 0xD10E, 0xD10F,
0xD110, 0xD111, 0xD112, 0xD113, 0xD114, 0xD115, 0xD116, 0xD117, 0xD118, 0xD119, 0xD11A, 0xD11B, 0xD11C, 0xD11D, 0xD11E, 0xD11F };


My three functions, 87-764-2800rev1.cpp, startup.cpp, and funcs.cpp all include the header, but so far, only 87-764-2800rev1.cpp uses the variables as such:

for(volatile int i = 0; i < 16; i++)
{
pkt.AddData((PBYTE)ADC, 2); // Send ADC Channel
pkt.AddData((PBYTE)ADC_RESULTS, 2); // Send ADC REsult for that channel
}

and

for(volatile int i = 0; i < 32; i++)
{
MUX_OUT = (MUX_STAT | 0xD000); // makes result 16 bits long, and in proper format
pkt.AddData((PBYTE)MUX_POS, 2); // Send MUX Channel
pkt.AddData((PBYTE)MUX_OUT, 2); // Send MUX REsult for that channel
}
User avatar
tony
Posts: 49
Joined: Thu Apr 24, 2008 6:05 pm

Re: MOD54415 compiler error messages

Post by tony »

Double check the files 87-764-2800rev1.cpp, startup.cpp, and funcs.cpp. Since you have the guard on your header, I think you must have declared the variables in one of the cpp files as well.
jediengineer
Posts: 192
Joined: Mon Dec 17, 2012 6:24 am

Re: MOD54415 compiler error messages

Post by jediengineer »

No Tony, I don't see it. I've checked it a few times now.
Post Reply