jbzdarkid
jbzdarkid

Reputation: 177

Compile failure when including files with GCC

I'm trying to compile a program with gcc, but I keep getting an error that it can't find the files I've specified to include. My code (a simplified version of what I'm trying to do which highlights the issue):

#include <gtk/gtk.h>
int main(int argc, char *argv[]) {

}

I'm compiling with gcc, using:

gcc test.c -I~/gtk/inst/include/gtk-2.0

which gives me

test.c:1:21: error: gtk/gtk.h: No such file or directory

However,

ls ~/gtk/inst/include/gtk-2.0/gtk | grep gtk.h

returns

gtk.h
gtkcheckbutton.h
gtkcheckmenuitem.h
gtkshow.h

so I'm not sure where I'm messing up. My OS is Mac OSX 10.8.5, and GCC is version 4.2.1.

Upvotes: 0

Views: 64

Answers (1)

l&#39;L&#39;l
l&#39;L&#39;l

Reputation: 47284

You should either:

  1. Put a space in front of the tilde:

-I ~/gtk/inst/include/gtk-2.0

  1. Use the absolute path:

-I /users/username/gtk/inst/include/gtk-2.0

  1. or use $HOME:

-I $HOME/gtk/inst/include/gtk-2.0

Shell only does tilde expansion if the ~ is the first nonquoted character in a word. The way you've got it now, shell has no clue that this is trying to point to the users home directory.

Upvotes: 1

Related Questions