vendredi 10 avril 2015

Explicitly mention the header files path to a gcc or g++ command


Vote count:

0




I'm trying to mention the header files path and run a c program using gcc.


My file is myfile.c



#include <stdio.h>
#include "myheader.h"

void main()
{
int num = NUM1;
printf("num=%d\n", num);
}


The header file myheader.h is present in /home/name/cTest/foo/myfile.h and its contents is



// myfile.h
#define NUM1 5


I run the command



gcc -I/home/name/cTest/foo myfile.c
or
gcc -I /home/name/cTest/foo myfile.c


I get an error



myfile.c:2:22: fatal error: myheader.h: No such file or directory
compilation terminated.


The version of gcc used.


gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3 Copyright (C) 2011 Free Software Foundation, Inc.


on Ubuntu 12.04 LTS


What could be possibly wrong?



asked 2 mins ago







Explicitly mention the header files path to a gcc or g++ command

Aucun commentaire:

Enregistrer un commentaire