Trevor Thomas
Trevor Thomas

Reputation: 79

MPLAB unable to combine .s and .c files

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?

Upvotes: 0

Views: 550

Answers (1)

C_Elegans
C_Elegans

Reputation: 1133

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.

Upvotes: 4

Related Questions