0

I am using MPLAB v4.0.5 on my Mac, with the XC16 v1.33 compiler. I have two files, thom5409_disc2_main_v001.s and thom5409_disc2_main_v001.c .

The following code was provided to help get us started and other students in my class were able to get the same exact code to build with no changes, so I believe it is an issue with my version of MPLAB or the compiler.

So basically, my assembly code looks like this: AssemblyCode

And my c code looks like this enter image description here

When I try to build it, I get the following errors:

multiple definition of '_counter' and multiple definition of '_myAsmFunc'

When I remove the lines in the assembly file that say .global _myAsmFunc and .global _counter

I get the following errors instead: undefined reference to '_main' and undefined reference to '_myGlobalVar'

I have tried debugging and figuring out a solution to this, but I can't seem to figure it out. As mentioned before, other classmates using various machines and versions of both MPLAB and the XC compiler were able to get it to work, so I don't believe it is a code issue, but maybe I have to change the code a little bit for MPLAB or the compiler?

Community
  • 1
  • 1
  • 3
    Please post code as text. My compiler has no [OCR](https://en.wikipedia.org/wiki/Optical_character_recognition) ability, nor can I copy/paste to a text editor – Weather Vane Feb 03 '18 at 23:41

1 Answers1

4

Both files will be compiled to thom5409_disc2_main_v001.o. What you should do is rename one of the files so that the .c and .s files get compiled to different object files.

C_Elegans
  • 1,113
  • 8
  • 15