CHANGING HEADER FILE NAME IN MPLAB. - Page 1
Forum section: electronics / beginners

author: neko efecktz
author_rank: Regular Contributor
timestamp: May 22, 2017, 12:30:51 am
content: Good morning all.Just a quick one.I want to change the name of a header file from lcd.H to lcd_v1.hI have designed a new PCB with most of the ports changed.I want to be able to program either of the boards just by changing the #include statement.It was#include "lcd.h" but is now#include "lcd_v1.h"Why would the compiler be looking for the original header file name of lcd.h???EDIT... even after closing MPLAB and restarting, Also shutting down the computer has no effect.below is the compile message...make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-confmake: Entering directory `C:/Users/BILL/Documents/MPLAB_PROJECTS/PIC16F877A LCD/PIC16F877A LCD.X'make -f nbproject/Makefile-default.mk dist/default/production/PIC16F877A_LCD.X.production.hexmake: *** No rule to make target `lcd.h', needed by `build/default/production/main.p1'. Stop.make: *** [.build-conf] Error 2make: *** [.build-impl] Error 2make: Entering directory `C:/Users/BILL/Documents/MPLAB_PROJECTS/PIC16F877A LCD/PIC16F877A LCD.X'make: Leaving directory `C:/Users/BILL/Documents/MPLAB_PROJECTS/PIC16F877A LCD/PIC16F877A LCD.X'make: Leaving directory `C:/Users/BILL/Documents/MPLAB_PROJECTS/PIC16F877A LCD/PIC16F877A LCD.X'BUILD FAILED (exit value 2, total time: 865ms)ThanksBILL.

author: rstofer
author_rank: Super Contributor
timestamp: May 22, 2017, 03:10:31 pm
content: Are you sure that main.p1 <whatever that is> doesn't contain a reference to lcd.h? Could lcd.h be included from another included file?It looks like the toolchain is using a Makefile. Perhaps the dependencies haven't been updated or the Makefile itself is out of date.

author: neko efecktz
author_rank: Regular Contributor
timestamp: May 23, 2017, 01:23:46 am
content: I have been through all of the files. 3 of them.There is no other reference to the original "lcd.h"The problem is easily fixed by just leaving the original file name but i am curious.The reason I want to have a second LCD header file is so I can just select the appropriate header depending on which board I am programming.thank youBILL.

author: KL27x
author_rank: Super Contributor
timestamp: May 23, 2017, 03:00:18 am
content: I dunno what version you are using. I use the old version, without the X.I am pretty sure I have experienced something potentially similar/same. And I believe it happens whenever:1.file>save as...2. the window opens, and the name of the original file is at the bottom under "file name:" in blue highlight. Let's say the name of this file is "header file."3. But instead of changing the name there to "header file v2," by keyboard, I instead click on another copy I have made of this file which was named "header file v1," as if I want to save over it... but actually I just did it in order to make "header file v1" pop up so I could edit just 1 number, if you know what I mean?I can't be positive this is related. But this is something I obviously avoid doing, now.*And no, I don't know how to fix it, after the fact. To this day I have some major projects where I can't change the file name... I assume I could fix it by building a new project, but meh...One workaround I happen to prefer anyhow is to use directives to conditionally assemble (I assume works same for compiling; it's been a long time since I compiled any C code):single universal header file.incIf headerfile.revision.constant == 0x01(header file for revision 1)endifif headerfile.revision.constant ==0x02(header file for revision 2)endifThen at the top of my main code page, I define these constants.Constant headerfile.revision.constant = 0x01 ; note to self: valid range 0x01 to 0x02On the surface, this is more work. And it makes the code less legible (in assembly, it's not particularly legible, to begin with) But on to the pro's:This is especially nice if, say, most of the header file is the same, anyway. And there are only select changes that need to be made. When you edit the header, you have access to all variations in one file. Most importantly, and this is the real key, is that all your "options" (assembly/compiling variants which in my case have included memory defines, code, eeprom initialization, even device type, etc etc in order to cover firmware variations, board revisions, and component changes) are contained in one place within your constant defines in your main code file. Whereas your actual "#include"'s would have to be scattered around to their respective places. And chasing them down would be annoying. You may even forget these options exist unless you say document their existence at the top of your main code page.... which is also where you can simply place these constant defines.

author: Mechatrommer
author_rank: Super Contributor
timestamp: May 23, 2017, 05:53:32 am
content: try cleaning all build files first and then recompile.

author: neko efecktz
author_rank: Regular Contributor
timestamp: May 23, 2017, 08:56:36 am
content: I managed to get it to work.I tried it three times and was able to get it working.step 1 change #include "filename"step 2 run build main project.will get error message.step 3 rename the header file by right clickingstep 4 run build main project.step 5 if it works, send me $25.00

author: Luminax
author_rank: Regular Contributor
timestamp: May 23, 2017, 09:59:59 am
content: I do believe that it is as Mechatrommer said, you need to do the 'clean and build' if you encounter such error.I think it's the linker just linking all the old object files...