[英]How to handle linker errors in C++/GNU toolchain?
给定一个C ++ / GNU工具链,什么是解决链接器错误的好方法或工具或策略?
Not sure exactly what you mean but if you are talking about cryptic linker symbols like: 不确定确切的意思,但是如果您正在谈论诸如以下这样的隐秘链接器符号:
mylib.so: undefined symbol: _ZN5CandyD2Ev mylib.so:未定义符号:_ZN5CandyD2Ev
you can use c++filt to do the puzzling for you. 您可以使用c ++ filt为您解决难题。
c++filt _ZN5CandyD2Ev C ++过滤_ZN5CandyD2Ev
will return Candy::~Candy() so somehow Candy's destructor didn't get linked. 将会返回Candy ::〜Candy(),因此不知道Candy的析构函数没有被链接。
Well the first thing would be RTFM. 那么第一件事就是RTFM。 No, seriously, read the documentation. 不,认真阅读文档。
If you don't want to do that, try a search on the error that comes up. 如果您不想这样做,请尝试搜索出现的错误。
Here are a few other things to remember: "missing" symbols are often an indication that you haven't included the appropriate source or library; 还有一些其他需要记住的事情:“缺失”符号通常表示您没有包括适当的源代码或库; "missing" symbols are sometimes an indication that you're attempting to link a library created with a different mangling convention (or a different compiler); 有时,“缺少”符号表示您正在尝试链接使用不同的处理约定(或不同的编译器)创建的库。 make sure that you have extern "C" where appropriate; 确保在适当的地方加上“ C”字样; declaring and defining aren't the same thing; 声明和定义不是一回事; if your compiler doesn't support "export" make sure your template code is available for when you instantiate objects. 如果您的编译器不支持“导出”,请确保在实例化对象时可使用模板代码。
Look at the names of the symbols that are reported to be problematic. 查看报告有问题的符号的名称。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.