GCC can't locate headers even when the search directory is correct
Once again, GCC is making me feel like an idiot for having trouble with the simplest things. I've included a header:
#include "PDL.h"
Then, I try to compile:
arm-none-linux-gnueabi-gcc -I/cygdrive/c/PalmPDK/include -I../lua-5.1.4/lua-webos/include -O2 -Wall -shared -nostdlib -mcpu=arm1136jf-s -mfpu=vfp -mfloat-abi=softfp -lpdl
开发者_JAVA百科But it says:
PDL.h: no such file or directory
I can change into the include directory I specified above and see PDL.h is there, but GCC just doesn't see it.
/cygdrive is something specific to cygwin, so if gcc isn't compiled to use the cygwin unix emulation layer, it won't search it. Try using -IC:/PalmPDK/include
.
If you have spaces in the path you'll need to escape them or surround the path with double quotes.
Assuming you're on a Linux box, or some flavor of Unix:
ls -l /
ls -l /cygdrive
ls -l /cygdrive/c
ls -l /cygdrive/c/PalmPDK
ls -l /cygdrive/c/PalmPDK/include
You will probably find your answer in the results of one of the commands listed above.
The #include "file.h"
syntax looks in the current directory, then in the default include directories for the header file. Instead, use the #include <file.h>
syntax in order to pick up the directories specified on the command-line.
If you want to use the quoted-filename syntax, use the syntax -iquoteFOLDER_PATH
to point to your include directory on the command-line.
Edit: Given your comment about the makefile, make sure that you have set (and export
) the SHELL
variable in your makefile. When running Cygwin under Windows, you can set it to cmd.exe or to Cygwin bash (works best if you include the full path to each). Whichever environment you list in your SHELL
variable will be used to execute the commands in the makefile. You can use whatever shell you wish, just make sure to specify one or the other so you can be sure that you are using the correct path style for the given shell. For good measure, also set (and export
) the MAKESHELL
variable using the same value.
精彩评论