编译器错误:体系结构x86_64的未定义符号 [英] Compiler Error: Undefined symbols for architecture x86_64

查看:94
本文介绍了编译器错误:体系结构x86_64的未定义符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试编译时出现此奇怪错误。

I'm getting this weird error when I try to compile.

x86_64体系结构的未定义符号:
readRecipe(std :: basic_istream< char,std :: char_traits< char>& ;, std :: basic_ostream< char,std :: char_traits< char>& ;, Cookbook&) :cclDKibb.o中的
_main
ld:针对体系结构x86_64
collect2找不到符号:ld返回1个退出状态

Undefined symbols for architecture x86_64: readRecipe(std::basic_istream<char, std::char_traits<char> >&, std::basic_ostream<char, std::char_traits<char> >&, Cookbook&), referenced from: _main in cclDKibb.o ld: symbol(s) not found for architecture x86_64 collect2: ld returned 1 exit status

这是它所指的功能:

void readRecipe(std::ifstream &istr, std::ofstream &ostr, Cookbook &cookbook)
{
    int units; std::string name, name2; 
    // Read recipe name. 
    istr >> name; 

     // Build the new recipe Recipe r(name);

    while (1)
    { 
        istr >> units; 
        if (units == 0)
            break; 
        assert (units > 0);

        istr >> name2; 
        Ingredient i(name2, units); 
        r.addIngredient(i);
    }

    // Add it to the list. 
    if (cookbook.addRecipe(r, ostr))
        ostr << "Recipe for " << name << " added" << std::endl; 
    else 
        ostr << "Recipe for " << name << "already exists" << std::endl;
}

有什么想法吗?

推荐答案

我知道了。我对该函数的原型搞砸了。

I figured it out. My prototype for the function was messed up.

这篇关于编译器错误:体系结构x86_64的未定义符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆