我开始在我的 C++ 项目中使用 Tup。我目前的一个是游戏,分为 3 个部分:
- 第一个是主目录“osumax”;
- 第二个是我的游戏框架“osumax/Libraries/ns_framework”;
- 最后是游戏数据“osumax/Libraries/osumax_shared”的API;
目前,osumax_shared 中没有任何内容,因为我正在研究框架。
ns_framework 和 osumax_shared 是动态库(我在Linux下,所以有.so文件)。
libns_framework.so 构建时甚至没有警告,但是当主可执行文件的构建开始时,我有很多错误,只有未定义的引用。有些来自 ns_framework,我可以理解,但我也在使用 TinyXML2(随 apt-get 安装),并且该库中有许多未定义的引用。
这是完整的输出:
[ tup ] [0.000s] Scanning filesystem...
[ tup ] [0.130s] Reading in new environment variables...
[ tup ] [0.131s] Parsing Tupfiles...
1) [0.001s] build-linux-x86_64-debug
[ ] 100%
[ tup ] [0.136s] No files to delete.
[ tup ] [0.136s] Generating .gitignore files...
[ tup ] [0.265s] Executing Commands...
1) [0.466s] build-linux-x86_64-debug: Compiling Sources/Main.cpp...
* 2) build-linux-x86_64-debug: g++ -L./Libraries/ -lns_framework -ltinyxml2 -lsfml-system -lsfml-window -lsfml-graphics -o ./osumax Objects/Main.o
Objects/Main.o: In function `main':
/home/linkpy/Documents/Devel/C++/osumax/osumax/.tup/mnt/@tupjob-596/home/linkpy/Documents/Devel/C++/osumax/osumax/build-linux-x86_64-debug/Sources/Main.cpp:35: undefined reference to `tinyxml2::XMLDocument::XMLDocument(bool)'
/home/linkpy/Documents/Devel/C++/osumax/osumax/.tup/mnt/@tupjob-596/home/linkpy/Documents/Devel/C++/osumax/osumax/build-linux-x86_64-debug/Sources/Main.cpp:36: undefined reference to `ns::C_XmlObject::save(tinyxml2::XMLDocument&) const'
/home/linkpy/Documents/Devel/C++/osumax/osumax/.tup/mnt/@tupjob-596/home/linkpy/Documents/Devel/C++/osumax/osumax/build-linux-x86_64-debug/Sources/Main.cpp:36: undefined reference to `tinyxml2::XMLNode::InsertEndChild(tinyxml2::XMLNode*)'
/home/linkpy/Documents/Devel/C++/osumax/osumax/.tup/mnt/@tupjob-596/home/linkpy/Documents/Devel/C++/osumax/osumax/build-linux-x86_64-debug/Sources/Main.cpp:37: undefined reference to `tinyxml2::XMLDocument::Print(tinyxml2::XMLPrinter*)'
/home/linkpy/Documents/Devel/C++/osumax/osumax/.tup/mnt/@tupjob-596/home/linkpy/Documents/Devel/C++/osumax/osumax/build-linux-x86_64-debug/Sources/Main.cpp:35: undefined reference to `tinyxml2::XMLDocument::~XMLDocument()'
/home/linkpy/Documents/Devel/C++/osumax/osumax/.tup/mnt/@tupjob-596/home/linkpy/Documents/Devel/C++/osumax/osumax/build-linux-x86_64-debug/Sources/Main.cpp:35: undefined reference to `tinyxml2::XMLDocument::~XMLDocument()'
Objects/Main.o: In function `tinyxml2::XMLNode::FirstChildElement(char const*)':
/usr/include/tinyxml2.h:473: undefined reference to `tinyxml2::XMLNode::FirstChildElement(char const*) const'
Objects/Main.o: In function `tinyxml2::XMLElement::SetAttribute(char const*, char const*)':
/usr/include/tinyxml2.h:900: undefined reference to `tinyxml2::XMLElement::FindOrCreateAttribute(char const*)'
/usr/include/tinyxml2.h:900: undefined reference to `tinyxml2::XMLAttribute::SetAttribute(char const*)'
Objects/Main.o: In function `ns::C_XmlAbstractField::~C_XmlAbstractField()':
/home/linkpy/Documents/Devel/C++/osumax/osumax/.tup/mnt/@tupjob-596/home/linkpy/Documents/Devel/C++/osumax/osumax/build-linux-x86_64-debug/Libraries/ns_framework/Headers/ns/xml/C_XmlField.hpp:39: undefined reference to `vtable for ns::C_XmlAbstractField'
Objects/Main.o: In function `ns::C_XmlObject::C_XmlObject(std::string)':
/home/linkpy/Documents/Devel/C++/osumax/osumax/.tup/mnt/@tupjob-596/home/linkpy/Documents/Devel/C++/osumax/osumax/build-linux-x86_64-debug/Libraries/ns_framework/Headers/ns/xml/C_XmlObject.hpp:39: undefined reference to `vtable for ns::C_XmlObject'
Objects/Main.o: In function `Test::Test()':
/home/linkpy/Documents/Devel/C++/osumax/osumax/.tup/mnt/@tupjob-596/home/linkpy/Documents/Devel/C++/osumax/osumax/build-linux-x86_64-debug/Sources/Main.cpp:13: undefined reference to `ns::C_XmlObject::~C_XmlObject()'
Objects/Main.o: In function `ns::C_XmlAbstractField::C_XmlAbstractField()':
/home/linkpy/Documents/Devel/C++/osumax/osumax/.tup/mnt/@tupjob-596/home/linkpy/Documents/Devel/C++/osumax/osumax/build-linux-x86_64-debug/Libraries/ns_framework/Headers/ns/xml/C_XmlField.hpp:17: undefined reference to `vtable for ns::C_XmlAbstractField'
Objects/Main.o:(.data.rel.ro._ZTV4Test[_ZTV4Test]+0x20): undefined reference to `ns::C_XmlObject::load(tinyxml2::XMLDocument const&, tinyxml2::XMLElement const*)'
Objects/Main.o:(.data.rel.ro._ZTV4Test[_ZTV4Test]+0x28): undefined reference to `ns::C_XmlObject::save(tinyxml2::XMLDocument&) const'
Objects/Main.o: In function `Test::~Test()':
/home/linkpy/Documents/Devel/C++/osumax/osumax/.tup/mnt/@tupjob-596/home/linkpy/Documents/Devel/C++/osumax/osumax/build-linux-x86_64-debug/Sources/Main.cpp:9: undefined reference to `ns::C_XmlObject::~C_XmlObject()'
Objects/Main.o:(.data.rel.ro._ZTIN2ns10C_XmlFieldIiEE[_ZTIN2ns10C_XmlFieldIiEE]+0x18): undefined reference to `typeinfo for ns::C_XmlAbstractField'
Objects/Main.o:(.data.rel.ro._ZTI4Test[_ZTI4Test]+0x10): undefined reference to `typeinfo for ns::C_XmlObject'
Objects/Main.o: In function `ns::C_XmlField<int>::write(tinyxml2::XMLDocument&, tinyxml2::XMLElement*) const':
/home/linkpy/Documents/Devel/C++/osumax/osumax/.tup/mnt/@tupjob-596/home/linkpy/Documents/Devel/C++/osumax/osumax/build-linux-x86_64-debug/Libraries/ns_framework/Headers/ns/xml/C_XmlField.hpp:221: undefined reference to `tinyxml2::XMLDocument::NewElement(char const*)'
/home/linkpy/Documents/Devel/C++/osumax/osumax/.tup/mnt/@tupjob-596/home/linkpy/Documents/Devel/C++/osumax/osumax/build-linux-x86_64-debug/Libraries/ns_framework/Headers/ns/xml/C_XmlField.hpp:223: undefined reference to `tinyxml2::XMLDocument::NewText(char const*)'
/home/linkpy/Documents/Devel/C++/osumax/osumax/.tup/mnt/@tupjob-596/home/linkpy/Documents/Devel/C++/osumax/osumax/build-linux-x86_64-debug/Libraries/ns_framework/Headers/ns/xml/C_XmlField.hpp:223: undefined reference to `tinyxml2::XMLNode::InsertFirstChild(tinyxml2::XMLNode*)'
/home/linkpy/Documents/Devel/C++/osumax/osumax/.tup/mnt/@tupjob-596/home/linkpy/Documents/Devel/C++/osumax/osumax/build-linux-x86_64-debug/Libraries/ns_framework/Headers/ns/xml/C_XmlField.hpp:225: undefined reference to `tinyxml2::XMLNode::InsertEndChild(tinyxml2::XMLNode*)'
Objects/Main.o: In function `ns::C_XmlField<int>::read(tinyxml2::XMLElement const*)':
/home/linkpy/Documents/Devel/C++/osumax/osumax/.tup/mnt/@tupjob-596/home/linkpy/Documents/Devel/C++/osumax/osumax/build-linux-x86_64-debug/Libraries/ns_framework/Headers/ns/xml/C_XmlField.hpp:243: undefined reference to `tinyxml2::XMLNode::FirstChildElement(char const*) const'
/home/linkpy/Documents/Devel/C++/osumax/osumax/.tup/mnt/@tupjob-596/home/linkpy/Documents/Devel/C++/osumax/osumax/build-linux-x86_64-debug/Libraries/ns_framework/Headers/ns/xml/C_XmlField.hpp:250: undefined reference to `tinyxml2::XMLElement::GetText() const'
/home/linkpy/Documents/Devel/C++/osumax/osumax/.tup/mnt/@tupjob-596/home/linkpy/Documents/Devel/C++/osumax/osumax/build-linux-x86_64-debug/Libraries/ns_framework/Headers/ns/xml/C_XmlField.hpp:257: undefined reference to `tinyxml2::XMLElement::Attribute(char const*, char const*) const'
collect2: error: ld returned 1 exit status
*** tup errors ***
*** Command ID=598 failed with return value 1
tup error: Expected to write to file 'osumax' from cmd 598 but didn't
*** Additionally, command 598 failed to process input dependencies. These should probably be fixed before addressing the command failure.
[ ] 99%
*** tup: 1 job failed.
链接命令是这个:
g++ -L./Libraries/ -lns_framework -ltinyxml2 -lsfml-system -lsfml-window -lsfml-graphics -o ./osumax Objects/Main.o
我在这里给你两个 Tup 文件(对不起法语评论):
- 对于主文件夹(osumax):http ://pastebin.com/zKgzyYxt
- 对于第一个库(ns_framework):http ://pastebin.com/mhTA4p73
那么,这些错误是来自 Tup 构建系统,还是来自我?
我真的不明白我的错误在哪里,或者如果我做错了什么是 tup 配置。
谢谢你的帮助 !