Re: Can I include glib, gtk .h files in a .cc files



> Launcher/MyController.cc:2:18: error: glib.h: No such file or directory
> Launcher/MyController.cc:6:21: error: gtk/gtk.h: No such file or directory

Well, do you tell your compiler where the headers are? The compiler
doesn't go out looking all through your file system for them by
itself, you know... In all "normal" command-line compilers (even
Microsoft's) one uses -I options to do this. But presumably you use
some IDE contraption that "helpfully" hides all that from you.

> But when I rename my .cc files to .c file, then the compiler compiles fine.

Apparently then you have (in some IDE?) told the compiler where to
find the GLib and GTK+ headers when compiling C, but not when
compiling C++. There is no way to know the exact answer without
knowing exactly what tools you are using and exactly what you are
doing. And by describing that in enough detail, you will probably find
out the problem yourself, and also, few people will bother reading
such a boring explanation.

Anyway, if you code is valid C (as it seems, if you say it compiles if
you rename your .cc source files to .c, but don't change anything
*inside* the files), why do you insist on treating them as C++ then?
There is no such thing as "C/C++". C++ is much more complex than C. If
you actually are writing C, don't be ashamed to compile the code as C.

--tml


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]