Instead of copying source and self-written header files to a multi-file Studio project, there's a better way. Instructions apply to Studio 4.18, SP2. Create a folder for header files that you've written and a second folder for reusable C source code modules. Mine are "My_Includes" and "My_LIBs". Put all header files you've written in one and whatever reusable source modules in the other.
For Header Files:
1) Hit the "Edit current configuration options" button ( the white gear icon opposite-right to the "build" button ).
a) OR do: Project-> "configuration options"
2) Hit "include Directories" button and then the yellow folder near the upper right hand corner, then a browse box will open and you'll see 3 "..." Hit those and navigate to WHEREVER your include folder is and hit "ok" ( Of course you can add subdirectory folders ).
For source files:
Do the same with the "Libraries" button just below the "Include Directories" button for your source files. Such source files won't show up in your project folder, but that's ok.
---------------------------------------------------
Now with a new project open, you have to add whichever files are needed.
For Source Files:
In the project tree, right click the yellow "source files" and do "add existing source file(s)".
For Header Files:
Do the same steps with the "Header Files", in the project tree. You must also use #include "some_header_file" in each project C source file where it's needed. See abcminiuser's tutorial Modularizing C Code: Managing large projects if you don't understand my last sentence.
You don't have to add header files to that folder in the tree, but if you don't then the header files will appear in the "external dependencies" folder automatically. I like to see them in their own folder, apart from the system file "clutter" of the external d. folder.
----------------------------------------------------
Now in your project files you can just do, for example:
#include
OR
#include "spi.h"
etc. for all header files you've written and will use. For your C modules, just navigate to your LIBs folder in the project view and add them.
Advantages:
1) You don't have to hassle with navigate -> copy -> pasting them to the current project folder any more !
2) If you modify your modules / header files while still developing said files, then when you save the changes they apply to the master file and you're done. Much better than saving the project copy and STILL having to jump through hoops to have to save those changes to the master through a copy -> navigate to master-> paste ( "overwrite" it ). It especially saves time if you're modifying multiple module / header files ( just hit "save all" ) !
I used Studio for years to do multi-file projects the "hard" way and I thought I was stuck with it ( since I never bothered to read the entire Studio manual to learn about the 2 options mentioned above ). So for any 'freaks that stumble onto this before you find out via Studio's help file ( I got the idea that the Studio IDE MIGHT be able to do these things from a project book that used the MPLAB IDE :roll: ), this tut's for YOU ! :wink:
Jerome