samedi 18 avril 2015

First C++ program can't compile - Unsure where to put third party lib

I'm designing my first C++ program but I'm having a hard time understanding how to install and use a third party library called pugixml.


Here is my structure:



  • root/Makefile

  • root/src/main.cpp

  • root/include/pugi/pugixml.hpp

  • root/include/pugi/pugixml.cpp

  • root/include/pugi/pugiconfig.hpp


I believe I was meant to dump all the pugixml in a folder called pug in my includes folder and then refer to it from my Makefile like this;



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 run the Makefile or 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


This I've been told is due to thee fact that I have put the pugi cpp file in includes.


Question



  • Where should the various pugi files go, if not where I have put them?

  • How should I modify my Makefile accordingly?


Aucun commentaire:

Enregistrer un commentaire