David Brown
David Brown

Reputation: 36269

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

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.

Upvotes: 2

Views: 586

Answers (4)

bta
bta

Reputation: 45087

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.

Upvotes: 0

AProgrammer
AProgrammer

Reputation: 52324

/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.

Upvotes: 4

John R. Strohm
John R. Strohm

Reputation: 7667

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.

Upvotes: 0

Jay
Jay

Reputation: 14481

If you have spaces in the path you'll need to escape them or surround the path with double quotes.

Upvotes: 0

Related Questions