We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Folks,
I'm finding the handling of pathnames in an MDK 5.1 project very confusing, and neither the online docs nor previous messages in this forum have been useful.
Consider the following situation -- I have a project with the following folder structure:
PF <project folder> main.c subroutine.c subroutine.h ...<some other source files> ARM <folder created by MDK> MyProject.UVProj <UVision project file> ...<other stuff> GNU <folder created by MDK> ...<stuff>
This is also represented in a Group/File structure inside the MDK Project Navigator Pane as follows:
MyProject app main.c subroutine.c subroutine.h <some other source files...> core <some ARM startup code> Include utility.h
Note that all file references in the Project Navigator are correct in the sense that the little icon next to each one is filled in (not blank) and double clicking on it will open an editor pane with the file's text. File utility.h is not in the project folder, but external to it (up a couple levels and then down another branch).
Files subroutine.c and .h were also external to the project folder and I had trouble with the compiler finding them. Got 'error: #5: cannot open source input file "app_util.h": No such file or directory' error messages. Doesn't matter whether I include a complete, full absolute pathname for the file in its Options > Properties > Path: setting or a relative path (both of which work for opening the file for editing in MDK). What gives?
So here are some specific questions: 1. Why does the compiler fail to find files when the files' pathnames in the files' properties is correct? 2. Is there an "inheritance" mechanism for file pathnames of files added to the project that runs from the Project properties to the Group properties to the file properties? If so, how does it work? 3. Same question for Include paths (although here I suspect it's "multiple inheritance", i.e., include paths accumulate, rather than get replaced in traversal down the chain. 4. What are the guidelines for using absolute vs. relative pathnames. (In one response on this list, it was suggested that relative paths should be used for files in the project folder, absolute paths otherwise.) 5. Most importantly, what's the root of relative paths? For an include file, is it the location of the file referencing it? Or the first level inside the project folder? The location of the .UVPROJ file? Or what? 6. For includes, is the search only one level deep or recursive? 7. For error #5, when the compiler fails to find a file, why doesn't it at least indicate where it expected to find it? That would be a lot more useful :-) 8. Are there answers to these questions in the manuals, the online docs or this forum for these questions which I've missed? And how would I have found them? (For example, searching for "pathnames" in the online help only revealed a couple references to obsolete assembler info. A search in this forum only produced a user's query about why they were geting Error #5, followed by a snarky response complaining that the user asked an insufficiently detailed question. Hopefully, this one is detailed enough :-)
Sheesh.... this issue shouldn't be this difficult. Comments?
Mike
Note that the compiler will not care about any file-specific path you have specified for an include file in the project file. The path to the header file in the project file is just to allow the editor to open the file - and possibly for dependency calculations.
You either need to specify a global include search path for the project, or specify a path in every #include "xxx" statement.
Where and how? In the "Options for Target '...' > C/C++ > Include Paths:" settings? Does this only affect the expansion of search paths for include files? What about the path settings for other entries in the Project Navigator pane, e.g. the Includes group header? Am I to infer from your suggestion that almost all(?) of the pathname property settings in the Project Navigator are only used by the editor and not communicated to the compiler (which I suppose I can verify from the compiler command strings that are generated.
And if I "specify a path" in each #include statement, does it have to be an absolute path? If not and relative paths are OK, from what base location?
Thanks, but I'm afraid that your short answer raises as many questions as it answers. Is this stuff documented anywhere?
Mike (who used to program in LISP many years ago -- it may be an "opaque" language, but at least the semantics are well defined :-)
Think about it.
When a *.c file as a line:
#include "test.h"
The compiler then only has access to any path information that it has hard-coded, or that it receives as an option on the command line.
But a *.h file in the project doesn't represent something to build. Only the *.asm, *.c, *.cpp, ... files are processed to produce object files.
Not only that, but one *.c file could want one "test.h" file while another *.c file could want another "test.h" - which means that the IDE can't just try to merge any path from a *.h entry with the settings for a *.c file.
The project tree is just a nice way for you to be able to direct-access your header files. And the "Include Dependencies" will show the include files that the individual source files actually made use of - extracted from the dependency information produced by the compiler when it compiled the source file. Obviously since the process is compile and then extract dependency information, you can't expect the reverse. I.e. to later have that dependency list patched to get the compiler to open completely different header files.
So you either open the options for a specific *.c file and updates the field 'Include Paths'. Or you open the options for the target.