i have a program that compiles using the following:
g++ -I ../../include -I . -I ../ -I ../../ -I ../ Entity.cpp Attribute.cpp main.cpp -o main.o
The Attribute.cpp includes its header file, Attribute.h, and Attribute.cpp contains all the implementations of Attribute.h.
The Entity.cpp includes the header files Entity.h and Attribute.h, since Entity.cpp uses the Attribute class.
the main.cpp file includes a header file called XML.h, that just includes both the Attribute and Entity headers.
the problem is i keep getting undefined references to functions used in main.cpp and Entity.cpp.
/tmp/ccxKUUNI.o: In function `Entity::entityString() const': Entity.cpp:(.text+0x3b0): undefined reference to `Attribute::getValueString() const' Entity.cpp:(.text+0x3c0): undefined reference to `Attribute::getName() const' /tmp/ccxKUUNI.o: In function `Entity::findAttributePosition(std::basic_string, std::allocator > const&)': Entity.cpp:(.text+0xb4e): undefined reference to `Attribute::equals(std::basic_string, std::allocator > const&) const' /tmp/ccxKUUNI.o: In function `Entity::findAttributePositionConst(std::basic_string, std::allocator > const&) const': Entity.cpp:(.text+0xc24): undefined reference to `Attribute::equals(std::basic_string, std::allocator > const&) const' /tmp/ccxKUUNI.o: In function `Entity::getAttributeValueString(std::basic_string, std::allocator > const&) const': Entity.cpp:(.text+0xe0a): undefined reference to `Attribute::getValueString() const' /tmp/ccvaLwbi.o: In function `main': main.cpp:(.text+0x2bc): undefined reference to `Entity::addAttribute(Attribute const&)' main.cpp:(.text+0x359): undefined reference to `Entity::addAttribute(Attribute const&)' main.cpp:(.text+0x4bb): undefined reference to `Entity::addAttribute(Attribute const&)' main.cpp:(.text+0x61d): undefined reference to `Entity::addAttribute(Attribute const&)' main.cpp:(.text+0x77f): undefined reference to `Entity::addAttribute(Attribute const&)' /tmp/ccvaLwbi.o:main.cpp:(.text+0x8e1): more undefined references to `Entity::addAttribute(Attribute const&)' follow /tmp/ccvaLwbi.o: In function `main': main.cpp:(.text+0xc65): undefined reference to `Entity::addEntity(Entity const&)' main.cpp:(.text+0xd68): undefined reference to `Entity::addAttribute(Attribute const&)' main.cpp:(.text+0xea9): undefined reference to `Entity::addEntity(Entity const&)' main.cpp:(.text+0xee1): undefined reference to `Entity::addEntity(Entity const&)' main.cpp:(.text+0xf53): undefined reference to `Entity::addEntity(Entity const&)'
I know these functions are defined, because their implementations are written in the corresponding cpp files, ie. Entity.cpp and Attribute.cpp.
Thanks.