In my code I make reference this pugixml like this:
#include "pugi/pugixml.hpp"
When compiling I get this error:
main in main-bf0b72.o
"pugi::xml_node::children(char const*) const", referenced from:
_main in main-bf0b72.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [main] Error 1
From another question I was told to pugi as an additional translation unit and link them accordingly like this in my Makefile:
CC = g++
CFLAGS = -g -Wall -std=c++11
SRC = src
INCLUDES = include
TARGET = main
all: $(TARGET)
$(TARGET): $(SRC)/$(TARGET).cpp pugi/pugixml.cpp
$(CC) $(CFLAGS) -I $(INCLUDES) -o $@ $^
clean:
$(RM) $(TARGET)
However when I try to run my Makefile after this change I get this error:
make: *** No rule to make target `pugi/pugixml.cpp', needed by `main'. Stop.
I'm really not sure what I am meant to be doing. Should pugi have it's own Makefile to build it individually, or should I give it is't own "target" in my Makefile?
Edit This is my file system:
- root/Makefile
- root/src/main.cpp
- root/include/pugi/pugixml.hpp
- root/include/pugi/pugixml.cpp
- root/include/pugi/pugiconfig.hpp
pugi/pugixml.cpp
on your filesystem? – myautMakefile
will be helpful – myaut