在 C++ 中取消定义对函数的引用
undefines reference to function in c++
我有一个名为元数据的类,它在namespace A::B::C
中声明,其中还包含struct copyInfo
,其中包含有关元数据的信息。因此,元数据只有其默认的构造器/析构函数,当我尝试使用元数据中称为的成员函数时 importMetadata(vector<copyInfo> &info, const string &src, const string &dst, const int &job:
我收到以下错误:
import_helper.cpp:(.text+0x246): undefined reference to
A::B::C::Metadata::importMetadata(std::vector<A::B::C::copyInfo, std::allocator<A::B::C::copyInfo> >&,
std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&,
std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int const&)
namespace A{
namespace B{
namespace C{
class Metadata{
Metadata();
~Metadata();
importMetadata(vector<copyInfo> &seq, const string &src,
const string &dst, const int &job);
/* more code down here */
};
}
}
}
现在,在Metadata
我有:
该函数是从一个名为 wrapperMetadataImport
的包装器 c++ 函数调用的,该函数属于 import_helper.cpp
。
#include "Metadata.h"
using namespace A::B::C;
int wrapperMetadataImport(const char * src, const char * dest, const int * jobid){
Metadata mtd;
string src = srcName;
string dest = destName;
vector<copyInfo> sequence;
/* add elemens to the vector sequence */
if((ret = mtd.importMetadata(sequence,
src, dest, *jobid)) == EC_success){
/* more code down here */
我不知道为什么我会得到这个。我已经检查了.h和.cpp文件,对我来说一切听起来都不错。我想这是一个运行时链接问题。命名空间应按原样排列:A::B::C
。有什么想法吗?
这是一个链接器错误,指示找不到函数的实现。要么尚未编写函数,要么尚未在生成中包含包含该函数的源文件。
您已在类定义中声明了它,但没有完整定义,则无法调用该函数。
相关文章:
- 区分接受常量参数的函数引用/指针和与函数参数同名的非常量参数
- 类 Referention 中C++回调函数引用非静态函数
- 使用函数引用指向节点的指针删除链表中的节点?
- 解释通过从函数引用返回数组的语法
- "Class1"类"Class2"对象作为私有数据成员。如何通过"Class 2"函数引用"Class1"对象?
- 使用默认构造函数引用成员变量初始化错误
- 无法调用函数引用 c++
- 使用 decltype(this) 获取函数引用
- 我应该如何定义返回指针的函数?(引用指针与指针指针)
- 从内联函数引用文件静态变量
- Boost::将sigaction函数引用绑定到实例
- 一种比函数引用更有效的方法
- 奇怪的未定义函数引用,函数调用C++不存在
- 是否可以检测绑定成员函数引用的对象是否被删除或销毁
- 构造函数引用参数导致seg错误
- 是否可以使函数模板从函数引用中获取“decltype”
- 无法让 Lua 函数引用"self"
- 如何解析变量和函数引用(Linker & Compiler)?
- 从不同模块调用函数 - 引用错误
- 如何在主函数中连接到数据库,然后从其他函数引用它