Fatal Error: No such file or directory. Compilation Terminated.

Post
Mike D
New Member
2011/08/09 13:44:57
Hi All,
 
I've been programming in C18 (for my 18F8722) for a while now, but I recently got the PIC32 Ethernet Starter Kit, and I'm finding myself a little stuck with C32.
 
When I compile the example programs from the C32 User's Guide, for example:
 
#include <p32xxxx.h>
unsigned int x, y, z;
unsigned int
add(unsigned int a, unsigned int b)
{
return(a+b);
}
int
main(void)
{
x = 2;
y = 5;
z = add(x,y);
return 0;
}
 
It compiles correctly with no errors.  However, when I want to write the example program for the device on the development board (PIC32MX795F512L) I change the first line to:
 
#include <p32mx795f512l.h>
 
Which I have checked is in the directory C:\Program Files\Microchip\mplabc32\v2.00\pic32mx\include\proc with all the other device-specific header files.  When I try to compile I get the following error message:
 
PIC32 Example 1.c:1:27: fatal error: p32mx795f512l.h: No such file or directory
compilation terminated.
 
I have made sure to add this header file to the project, and have tried adding it using the "Auto" option (where MPLAB decides whether to use a relative or absolute path to the file) as well as the "Copy" option (where the header file is copied to the project directory).  I have also tried not adding the header file to the project, and that still doesn't work.
 
This same error seems to be happening whenever I try to include one of the header files included in C:\Program Files\Microchip\mplabc32\v2.00\pic32mx\include\. 
 
Is there a special way that I need to be adding header files to the project?
 
Also, are there device-specific linker scripts I should be adding to the project?  I know I had to do this in C18, but I can't find a directory in C:\Program Files\Microchip\mplabc32\v2.00\ that includes these linker scripts.
 
I'm hoping to get past this early road block soon and start working with my new PIC32!  Any help would be greatly appreciated.
 
--Mike D
 
 
jb007
New Member
Re:Fatal Error: No such file or directory. Compilation Terminated. 2011/08/09 16:37:57
Hi Mike. Firstly I'm a complete newbie, so take what follows with a grain of salt!

I think you have to leave <p32xxxx.h> in the header and select your correct target device in the project properties. I think at compile time it then links in the correct device header(s).

Regards,

Jim 
aschen0866
Super Member
Re:Fatal Error: No such file or directory. Compilation Terminated. 2011/08/09 17:08:58
If you don't want to use p32xxxx.h, you'll have to write this:

#include <proc/p32mx795f512l.h>

Mike D
New Member
Re:Fatal Error: No such file or directory. Compilation Terminated. 2011/08/10 14:07:15
Thanks aschen, I guess I didn't read far enough in the C32 User's Guide.  In Chapter 4 it comments on using the #include <proc/xxxxxx> format for some header files.
JasonK
Moderator
Re:Fatal Error: No such file or directory. Compilation Terminated. 2011/08/10 14:12:41
You should really just use p32xxxx.h, it provides some convenience macros and then does a #include <proc/xxxx.h> based on the selected device. There's really no reason to include the <proc/xxxx.h> header file directly.


aschen0866
Super Member
Re:Fatal Error: No such file or directory. Compilation Terminated. 2011/08/10 14:56:42
JasonK
...  There's really no reason to include the <proc/xxxx.h> header file directly.

Hi, Jason,
I know the main reason for people to use a specific processor header file instead of the xxxx version is that it is not always desirable to commit MPLAB IDE's .mcw file into their version control software. I see later version of MPLAB IDE's .mcp file contains a "device" field, for example, my project's .mcp file shows:

[HEADER]
magic_cookie={66E99B07-E706-4689-9E80-9B2582898A13}
file_version=1.0
device=PIC32MX795F512L  <==================
[PATH_INFO]
...

So, does this mean that MPLAB IDE will use this field to determine what processor shall be used for the project?
JasonK
Moderator
Re:Fatal Error: No such file or directory. Compilation Terminated. 2011/08/11 22:31:04
So, does this mean that MPLAB IDE will use this field to determine what processor shall be used for the project? 

To be honest, I don't know how MPLAB IDE v8 uses the device name in the project file.


For the #include thing, it might be better to put a check in the code. For instance

#ifndef __32MX795F512L__  
#error Select the correct device from the MPLAB IDE v8 Configure Menu 
#endif 
#include <p32xxxx.h>

That way you can still use the macros defined at the bottom of the p32xxxx.h header. On the other hand, if you don't need those macros, it doesn't really matter.


P.S. Sorry for the lack of code tags in the snippet. The forum apparently doesn't like line breaks from my Mac.
post edited by JasonK - 2011/08/11 22:34:52
aschen0866
Super Member
Re:Fatal Error: No such file or directory. Compilation Terminated. 2011/08/12 07:00:46
JasonK

For the #include thing, it might be better to put a check in the code. For instance

#ifndef __32MX795F512L__  
#error Select the correct device from the MPLAB IDE v8 Configure Menu 
#endif 
#include <p32xxxx.h>
...

I've been use #warning and #error in my code but somehow it never occurs to me to use them for processor selection. Thanks.