私は以下を使用してコンパイルするプログラムを持っています:
g++ -I ../../include -I . -I ../ -I ../../ -I ../ Entity.cpp Attribute.cpp main.cpp -o main.o
Attribute.cpp にはそのヘッダー ファイル Attribute.h が含まれており、Attribute.cpp には Attribute.h のすべての実装が含まれています。
Entity.cpp は Attribute クラスを使用するため、Entity.cpp にはヘッダー ファイル Entity.h および Attribute.h が含まれます。
main.cpp ファイルには XML.h というヘッダー ファイルが含まれており、属性ヘッダーとエンティティ ヘッダーの両方が含まれています。
問題は、main.cpp と Entity.cpp で使用される関数への未定義の参照を取得し続けることです。
/tmp/ccxKUUNI.o: 関数 `Entity::entityString() const' 内: Entity.cpp:(.text+0x3b0): `Attribute::getValueString() const' への未定義の参照 Entity.cpp:(.text+0x3c0): `Attribute::getName() const' への未定義の参照 /tmp/ccxKUUNI.o: 関数内 `Entity::findAttributePosition(std::basic_string, std::allocator > const&)': Entity.cpp:(.text+0xb4e): `Attribute::equals(std::basic_string, std::allocator > const&) const' への未定義の参照 /tmp/ccxKUUNI.o: 関数内 `Entity::findAttributePositionConst(std::basic_string, std::allocator > const&) const': Entity.cpp:(.text+0xc24): `Attribute::equals(std::basic_string, std::allocator > const&) const' への未定義の参照 /tmp/ccxKUUNI.o: 関数内 `Entity::getAttributeValueString(std::basic_string, std::allocator > const&) const': Entity.cpp:(.text+0xe0a): `Attribute::getValueString() const' への未定義の参照 /tmp/ccvaLwbi.o: 関数 `main' 内: main.cpp:(.text+0x2bc): `Entity::addAttribute(Attribute const&)' への未定義の参照 main.cpp:(.text+0x359): `Entity::addAttribute(Attribute const&)' への未定義の参照 main.cpp:(.text+0x4bb): `Entity::addAttribute(Attribute const&)' への未定義の参照 main.cpp:(.text+0x61d): `Entity::addAttribute(Attribute const&)' への未定義の参照 main.cpp:(.text+0x77f): `Entity::addAttribute(Attribute const&)' への未定義の参照 /tmp/ccvaLwbi.o:main.cpp:(.text+0x8e1): `Entity::addAttribute(Attribute const&)' への未定義参照が続きます /tmp/ccvaLwbi.o: 関数 `main' 内: main.cpp:(.text+0xc65): 「Entity::addEntity(Entity const&)」への未定義の参照 main.cpp:(.text+0xd68): 「Entity::addAttribute(Attribute const&)」への未定義の参照 main.cpp:(.text+0xea9): `Entity::addEntity(Entity const&)' への未定義の参照 main.cpp:(.text+0xee1): `Entity::addEntity(Entity const&)' への未定義の参照 main.cpp:(.text+0xf53): `Entity::addEntity(Entity const&)' への未定義の参照
これらの関数の実装は対応する cpp ファイルに記述されているため、これらの関数が定義されていることはわかっています。Entity.cpp と Attribute.cpp。
ありがとう。