Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I need to be able to compile a piece of code at work that was originally written for Unix based systems. I am using cygwin and the GNU gcc. Every time I try to run the make command, the program seems to compile as it should but when it gets to timing.h it produces this error:

Compiling: timing.c timing.h... timing.c:1:0: warning: -fPIC ignored for target 
(all code is position independent)
 #include "timing.h"
In file included from timing.c:1:0: 
timing.h:5:26: fatal error: sys/resource.h: No such file or directory
 #include <sys/resource.h>
compilation terminated.
timing.h:1:0: warning: -fPIC ignored for target (all code is position independent)
 #include <sys/time.h>
timing.h:5:26: fatal error: sys/resource.h: No such file or directory
 #include <sys/resource.h>
compilation terminated.
make: *** [timing.o] Error 1

From what I have read, usually the cause of this kind of error is caused by an incorrect path. The contents of timing.h are as follows:

#include <sys/time.h>
#include <sys/types.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/resource.h>
void timing(double* wcTime, double* cpuTime);

The thing that baffles me is that even-though the files are in the same directory I only get the error as it tries to include the last file. I have made sure that the $C_INCLUDE_PATH points to where the files are.

$ echo $C_INCLUDE_PATH
/usr/include/

Any help would be awesome. This has stumped me for a few days now. I am running gcc version 4.9.0.

Are you using $C_INCLUDE_PATH in the command that invokes gcc? If you could include that command line it would help. – dma May 20, 2014 at 23:56 You'll have to see exactly what command the makefile is using to compile the file. I suggest running a 'make -n'. Usually that will show you. I suspect that it is using a -nostdinc option or some other way of eliminating the search of the default system directories. But this is merely a guess. If you can get the exact command line, you can add '-v' as one of the options and see exactly what gcc is attempting to do. – SeeJayBee May 21, 2014 at 0:44 As far as I know I am using the include path that invokes gcc. If I grep the file I cant seem to find, I get $ cygcheck -l cygwin | grep resource.h /usr/include/sys/resource.h . The command I used to set the C_INCLUDE_PATH was: export C_INCLUDE_PATH=/usr/include/ – Jake May 21, 2014 at 16:40

Your cygwin /usr/include/sys directory appears to be missing the resource.h file.

I just checked my cygwin installation and resource.h and time.h are both present in /usr/include

You might be missing a cygwin package, or your cygwin installation may need to be updated.

That seems unlikely since sys/resouce.h is part of the base system. It's possible that the user doesn't have it, but that would indicate a corrupted install. – SeeJayBee May 21, 2014 at 0:39

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.