CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug Reports on this forum. Send them to support@ccsinfo.com

How to use multiple files with cmd line compiler in MPLAB X?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
PCM programmer



Joined: 06 Sep 2003
Posts: 21066

View user's profile Send private message

How to use multiple files with cmd line compiler in MPLAB X?
PostPosted: Thu Mar 19, 2020 1:22 am     Reply with quote

I'm using a 16F19186 and I want to use my Pickit 3 as a hardware
debugger to debug the lcd code. I have to use MPLAB X for this
because MPLAB v8.92 doesn't support the 16F19186.

How to configure MPLAB X to work with multiple files when using
the PCM command line compiler ? I don't have the IDE compiler.

I'm getting errors such as "Export requires IDE". It looks like MPLAB X
created a makefile designed for use with multiple compilation units.
But my PCM command line compiler doesn't support MCUs. Is there
a way to do this ?

I have PCM vs. 5.093.
Ttelmah



Joined: 11 Mar 2010
Posts: 15749

View user's profile Send private message

PostPosted: Thu Mar 19, 2020 2:09 am     Reply with quote

Start with your project.
Make sure that _only_ the primary code file is in the entry for 'source
files' in the project. Nothing else.
All other files whether .c or .h, are only placed in the 'header files' project
entry.
All the other entries for the project, leave empty.
Then ensure that your primary file is capable of being compiled on it's own.
Have it #include every other file it uses (in the correct order).
Ensure in the project properties, that 'Loading' is left empty, and
similarly 'Libraries' is left empty.
The makefile generated, should then just compile the single primary code
file, which then includes all other files.
MPLAB, only attempts to link, if you have multiple files in the source files
section of the project. It sounds as if you must have done this.

Just tested on my compiler with MPLAB5.30, and it merrily generates
this command line:

CCSC +Y=9 +EA +DF +LN +T +A +M +J +Z -P C:\Users\roger\AppData\Roaming\TOC\Toc.c

Which does not say to generate MCU's.

Provided you only have a single master file I can't see any reason for
it to be trying to use MCU's.

Funny thing is PCM, that on MPLAB, you answered exactly this question,
many years ago, in:

<https://www.ccsinfo.com/forum/viewtopic.php?t=47890>
PCM programmer



Joined: 06 Sep 2003
Posts: 21066

View user's profile Send private message

PostPosted: Thu Mar 19, 2020 5:45 am     Reply with quote

I got it working. I followed your instructions. But there was a problem
at the end.

First I shut down MPLAB X. Then using Windows 10 Explorer, I went to
This PC\OS (C:)\Users\Home\MPLABXProjects. I then deleted my entire
project folder so I could start over clean. I had my source files safely
stored in another folder on my desktop.

Next I made a new project, following the procedure in the CCS MPLAB X
tutorial. https://www.ccsinfo.com/pdfs/mplabx_ccs_tutorial.pdf

Then I added the main C source file to the Source Files folder in the
Project window. I ticked the 'copy' box before I did this.

Then I did the same for all the other files, putting them in the Header Files
folder in the Project Window. I did them all at once, also ticking the 'copy' box.

Then I compiled. I got errors: "#Device required before this line."
Instantly, I knew that MPLAB X was somehow including all those files in
the project.
But I remembered something I had seen an hour before. I went to
File / Project Properties and clicked on File Inclusion/Exclusion. I excluded
all files except the main C file and clicked Apply. Then it worked.
The files can also be excluded by right-clicking the Header Files folder
and ticking the Header Files box to exclude them all.

Yes, I know I shouldn't have put all my module files into the Source Files
folder. But it wasn't finding the files initially so I played around with it.
It was a mistake. But at least it's working now. Thank you for your help.
alan



Joined: 12 Nov 2012
Posts: 313
Location: South Africa

View user's profile Send private message

PostPosted: Thu Mar 19, 2020 6:01 am     Reply with quote

I rather include my files in the important files section, so they can be opened for editing without interfering with the compiler.
Ttelmah



Joined: 11 Mar 2010
Posts: 15749

View user's profile Send private message

PostPosted: Thu Mar 19, 2020 7:38 am     Reply with quote

Well done. It seems that Netbeans is automatically adding files that
are in the source directory when the project is created. Designed to
annoy!....
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group