C compiler preprocessor denies file is present

Asked by John Winterton on 2012-08-23

Thanks for your earlier help which got me to this conundrum.

By using the locate command, I was able to add all the necessary pathnames to my makefile to get all "missing file" errors resolved. Now, however, something that I just can't see has caused this result:

john@John-1204LTS:~/dev/OpenGLTest$ make
gcc -c main.c
main.c:24:23: fatal error: gdk/gdkgl.h: No such file or directory
compilation terminated.
make: *** [TestOpenGL] Error 1
john@John-1204LTS:~/dev/OpenGLTest$ locate gdkgl.h
/usr/include/gtkglext-1.0/gdk/gdkgl.h
/usr/include/gtkglext-1.0/gdk/gdkgl.h.gch
john@John-1204LTS:~/dev/OpenGLTest$

When I believe that the appropriate paths are present in the makefile:

 CPPFLAGS=-I /usr/include/gtkglext-1.0 -I /usr/lib/gtkglext-1.0/include\
 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/gtk-2.0 -I /usr/include/pango-1.0\
 -I /usr/lib/x86_64-linux-gnu/gtk-2.0/include -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0\
 -I /usr/include/gtkglext-1.0
TestOpenGL : main.o
 gcc -c main.c

To correctly make the source:

#include <gdk/gdkgl.h>
#include <stdio.h>

int main(int argc, char **argv)
{
 if (gdk_gl_init_check( (int *)argc, (char ***)argv ) )
  printf("Successfully opened library\n");
 else
  printf("Open library failed\n");

 return 0;
}

I am using the documentation in Devhelp, specifically this description of initializing the library:

gdk_gl_init_check ()

gboolean gdk_gl_init_check (int *argc,
                                             char ***argv);
This function does the same work as gdk_gl_init() with only a single change: It does not terminate the program if the library can't be initialized. Instead it returns FALSE on failure.

This way the application can fall back to some other means of communication with the user - for example a curses or command line interface.

argc : Address of the argc parameter of your main() function. Changed if any arguments were handled.
argv : Address of the argv parameter of main(). Any parameters understood by gdk_gl_init() are stripped before return.
Returns : TRUE if the GUI has been successfully initialized, FALSE otherwise.

All I want to do is get a true/false from this function to verify the presence of the requirements. It is most annoying that the preprocessor should fail in this regard, because prior to this failure, all the other includes were acted upon or I could not have used locate to find the necessary libraries. I have not even been able to get so far as setting up the makefile to call the linker.

Please have someone familiar with this library have a look at this. I think it needs a second look by someone experienced with this package. I am pretty rusty to say the least. The last time I did any development of this type was around 1980.

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu gcc-defaults Edit question
Assignee:
No assignee Edit question
Solved by:
John Winterton
Solved:
2012-08-23
Last query:
2012-08-23
Last reply:
2012-08-23
Ubfan (ubfan1) said : #1

Use double quotes instead of the < > around the gdk... include.

John Winterton (jwinterton) said : #2

Tried that:
#include "gdk/gdkgl.h"
#include <stdio.h>

int main(int argc, char **argv)
{
 if (gdk_gl_init_check( (int *)argc, (char ***)argv ) )
  printf("Successfully opened library\n");
 else
  printf("Open library failed\n");

 return 0;
}

Result - no joy.

john@John-1204LTS:~/dev/OpenGLTest$ make
gcc -c main.c
main.c:24:23: fatal error: gdk/gdkgl.h: No such file or directory
compilation terminated.
make: *** [TestOpenGL] Error 1

Ubfan (ubfan1) said : #3

You have created a variable with the include paths to search, but have not included it on the compilation invocation.
e.g.
gcc $CPPFLAGS <Usually other variables which have been set up for library searches, etc> -c main.c

John Winterton (jwinterton) said : #4

Tried that with this result:

john@John-1204LTS:~/dev/OpenGLTest$ make
gcc PPFLAGS -c main.c
gcc: error: PPFLAGS: No such file or directory
make: *** [TestOpenGL] Error 1
john@John-1204LTS:~/dev/OpenGLTest$ cat makefile
CPPFLAGS=-I /usr/include/gtkglext-1.0 -I /usr/lib/gtkglext-1.0/include -I /usr/include/glib-2.0\
 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/gtk-2.0 -I /usr/include/pango-1.0\
 -I /usr/lib/x86_64-linux-gnu/gtk-2.0/include -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0\
 -I /usr/include/gtkglext-1.0
TestOpenGL : main.o
 gcc $CPPFLAGS -c main.c

However, I did manage to remember how to use variables in a make file. Your suggestion triggered my memory that the symbol has to be in parens.

This version worked fine. Thanks for the conversation. You were a great help.

john@John-1204LTS:~/dev/OpenGLTest$ cat makefile
CPPFLAGS=-I /usr/include/gtkglext-1.0 -I /usr/lib/gtkglext-1.0/include -I /usr/include/glib-2.0\
 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/gtk-2.0 -I /usr/include/pango-1.0\
 -I /usr/lib/x86_64-linux-gnu/gtk-2.0/include -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0\
 -I /usr/include/gtkglext-1.0
TestOpenGL : main.o
 gcc $(CPPFLAGS) -c main.c
john@John-1204LTS:~/dev/OpenGLTest$
john@John-1204LTS:~/dev/OpenGLTest$
john@John-1204LTS:~/dev/OpenGLTest$ make
gcc -I /usr/include/gtkglext-1.0 -I /usr/lib/gtkglext-1.0/include -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/gtk-2.0 -I /usr/include/pango-1.0 -I /usr/lib/x86_64-linux-gnu/gtk-2.0/include -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gtkglext-1.0 -c main.c
main.c: In function ‘main’:
main.c:29:25: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
john@John-1204LTS:~/dev/OpenGLTest$

John Winterton (jwinterton) said : #5

Working alone with no others around really sucks. You people are life savers.

jiji20 (jiji20) said : #6

usr/include/gdk-pixbuf-2.0 -I /usr/include/gtkglext-1.0 -c main.c
main.c: In function ‘main’:
main.c:29:25: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] https://tgw.onl/hostgator/ https://tgw.onl/dreamhost/ https://tgw.onl/bluehost/