0

I am currently working on an assignment that requires me to build a Makefile that

  • creates an include directory
  • copies math330.h file into the include directory
  • create a lib directory
  • compile the .c files in trig and exp as object files
  • make a library
  • install the library to the lib directory
  • compile the cli program against the include and library directory

So I have most of the coding down for this, but I keep getting errors for when i try to put the .o's for the trig functions in the include folder. The error is

trig/cos330.c:1:10: fatal error: 'math330.h' file not found

This is just the last part i need help with! Can someone give me hints about what I can do? Thanks!

all:
    mkdir -p ./include
    mkdir -p ./lib
    cp math330.h ./include
    gcc -l ./include/ -c trig/*.c
    gcc -l ./include/ -c exp/*.c
    mv *.o ./lib/
    ar r libmath.a lib/*
    mv libmath.a lib/
    gcc -l ./include/ cli/cli.c -L ./lib -lmath -lm

clean:
    rm -rf include
    rm -rf lib
    rm a.out
Tom Solid
  • 2,226
  • 1
  • 13
  • 32
Arby22
  • 13
  • 2
  • 1
    The `-l` option looks wrong. You want `-I` and/or maybe `-L`? – tripleee Apr 15 '16 at 07:19
  • That's definitely not a good way to create a `makefile`. Please read some introduction to writing makefiles, or find questions here on SO — there are plenty to choose from . And please don't go around deleting questions as soon as you get an answer; it is not a recipe for long-term popularity. – Jonathan Leffler Apr 15 '16 at 07:24

1 Answers1

1

The option to specify an include directory is capital-I (I), not lower-case L (l).

gcc -I ./include …

The lower-case ell indicates a library name. Given -l ./include, the poor linker would have a schizophrenic time looking for a library lib./include.a or lib./include.so to link with (possibly in the ./lib directory), and it probably wouldn't find it. But it doesn't get that far.

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278