| View previous topic :: View next topic   | 
	
	
	
		| Author | 
		Message | 
	
	
		
			PCM programmer
 
 
  Joined: 06 Sep 2003 Posts: 21708
  
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				| How to use multiple files with cmd line compiler in MPLAB X? | 
			 
			
				 Posted: Thu Mar 19, 2020 1:22 am     | 
				     | 
			 
			
				
  | 
			 
			
				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: 19967
  
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Thu Mar 19, 2020 2:09 am     | 
				     | 
			 
			
				
  | 
			 
			
				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: 21708
  
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Thu Mar 19, 2020 5:45 am     | 
				     | 
			 
			
				
  | 
			 
			
				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: 358 Location: South Africa 
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Thu Mar 19, 2020 6:01 am     | 
				     | 
			 
			
				
  | 
			 
			
				| 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: 19967
  
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Thu Mar 19, 2020 7:38 am     | 
				     | 
			 
			
				
  | 
			 
			
				Well done. It seems that Netbeans is automatically adding files that 
 
are in the source directory when the project is created. Designed to 
 
annoy!.... | 
			 
		  | 
	
	
		  | 
	
	
		 |