lundi 3 juin 2019

Why can't makefile find include directories

I can't seem to include a file in my test program using makefile.

I've attempted to try the relative path using -I with no luck. I'm new to Makefile and for some reason am having a hard time understanding it's usage.

my code, test.cpp

#include <iostream>
#include <results/enumTest.h>

int main()
{
   return 0;
}

and my makefile:

CFLAGS = -Wall -g -Wextra -Wpedantic -std=gnu++11 -m64 -Iinclude

test: test.o
    gcc $(CFLAGS) -I/.. -o  test test.o 

test.o: test.cpp
    gcc $(CFLAGS) -I/.. -c test.cpp

my directory structure:

/testDir/
  ./results/enuMtest.h
  ./test/test.cpp
  ./test/Makefile

I would hope that I could successfully compile and then run the test software using a Makefile. This is more or less a tutorial for me.

Aucun commentaire:

Enregistrer un commentaire