0

I am given a code that has the following headers:

#include <aio.h>
#include <fcntl.h>

I complie using the following makefile make -f makefile.make (on Mac OSX):

TARGET = run
LIBS = -O2 -lm
CC = gcc-7
CFLAGS = -fopenmp

.PHONY: default all clean

all: $(TARGET)

OBJECTS = $(patsubst %.c, %.o, $(wildcard *.c))
HEADERS = $(wildcard *.h)

%.o: %.c $(HEADERS)
    $(CC) $(CFLAGS) -c $< -o $@

.PRECIOUS: $(TARGET) $(OBJECTS)

$(TARGET): $(OBJECTS)
    $(CC) $(OBJECTS) $(CFLAGS) $(LIBS) -o $@

clean:
    -rm -f *.o
    -rm -f $(TARGET)

But I get this error:

In file included from main_seed.c:1:0:
seedio.h:4:10: fatal error: aio.h: No such file or directory
 #include <aio.h>
          ^~~~~~~
compilation terminated.
make: *** [main_seed.o] Error 1

This means I have to find these headers first. The problem is that I don't know ehere to find them. I could only find this documentation page but there is no download link so that I can include them in the folder project. Can someone help me to spot these files?

Thank you

Kristy
  • 251
  • 5
  • 12
  • it's #include "aio.h" if it's external header file created by the programmer – bigbounty Mar 13 '18 at 02:21
  • 2
    you have to specify the paths to search for header files on the compiler command-line. `#include` with angle-brackets _only_ uses the search path. `#include` with double-quotes also searches the directory containin the source file. Typically, you specify the search path to the compiler using `-I` (that's a capitol i). E.g., `gcc -I /my/path/include -c test.c`. You can use `-I` several times on a single invocation of the compiler. – lockcmpxchg8b Mar 13 '18 at 02:23
  • What compiler are you using? – Stephen Newell Mar 13 '18 at 02:24
  • @StephenNewell Thank you. I use gcc in mac osx .. I will update my post – Kristy Mar 13 '18 at 02:26
  • Somewhat related: http://c-faq.com/cpp/missinghdr.html – melpomene Mar 13 '18 at 02:36
  • Based on https://stackoverflow.com/questions/2211951/aio-on-os-x-vs-linux-why-it-doesnt-work-on-mac-os-x (specifically the update at the end of the question), OS X may not support AIO at all. – Stephen Newell Mar 13 '18 at 02:38
  • Quoting OP's link: "*[AIO] Asynchronous Input and Output. The functionality described is optional.*" – melpomene Mar 13 '18 at 02:39
  • 1
    On my Mac, I have the header `/usr/include/aio.h` (it includes `/usr/include/sys/aio.h` which contains lots of material) and `man aio_read()` presents useful information. Do you have the header? If not, you may need to install the command line tools (for XCode) to obtain it. Since `gcc-7` is not standard on Mac, you probably installed it from HomeBrew or somewhere similar — and you are now finding that the compiler can't compile if the headers aren't present. – Jonathan Leffler Mar 13 '18 at 03:36
  • @JonathanLeffler Thanks for your thoughts. I couldn't find `/usr/include/` do I have to create it manually? I do have command line tools though in my Mac – Kristy Mar 13 '18 at 14:05
  • No; you have to get the 'command line tools' for XCode. I've been a Mac developer for long enough that I've forgotten exactly what the rules are, but I think you can download XCode in full for free from the App Store, and then install the command line tools. There are other questions on SO with the information. Try searching for `xcode-select` — on your computer, it would be in `/usr/bin`; if not present, search on SO for `[c] xcode-select` (about 140 Q&A). Installing the XCode command line utilities gives you the system headers needed for compiling. (You'll use `xcode-select --install`.) – Jonathan Leffler Mar 13 '18 at 14:13

0 Answers0