在体系结构 + 链接器命令中找不到符号失败,退出代码为 1

Alo*_*rbe 4 c++ xcode linker command

我一直在为这个头疼。我已经搜索了所有我似乎发现的都是相同错误消息的问题,但涉及构建完整的 iphone 应用程序或处理头文件,各种各样的东西。

我只是在写一个简单的 C++ 程序,除了典型的 iostream、stdlib.h 和 time.h 之外没有头文件。这是一个非常简单的大学作业,但我不能继续工作,因为 Xcode 给了我这个与实际代码无关的错误(基于我读过的内容)。除了实际的 .cpp 文件之外,我没有弄乱任何东西,我什至不知道我怎么会弄乱它。我以同样的方式完成了多项作业,以前从未遇到过这个问题。

当前代码:

#include <iostream>
#include <stdlib.h>
#include <time.h>


using namespace std;

//functions
void funcion1(int matriz, int renglones, int columnas);
void funcion2(int matriz, int renglones, int columnas);

//variables
int renglones=8;
int columnas=8;
int ** matriz = new int*[renglones];

int main()
{   
    //reservar columnas
    for (int i=0; i < renglones; i++)
    {
        matriz[i] = new int[columnas];
    }

    srand(time(NULL));
    funcion1(**matriz, renglones, columnas);
    funcion2(**matriz, renglones, columnas);
}

void funcion1(int **matriz, int renglones, int columnas)
{
    for (int y = 0; y <= renglones; y++)
    {
        for (int x = 0; x <= columnas; x++)
        {
            matriz[y][x] = rand() % 10;
        }
    }
}

void funcion2(int **matriz, int renglones, int columnas)
{
    for (int y = 0; y <= renglones; y++)
    {
        for (int x = 0; x <= columnas; x++)
        {
            cout << matriz[y][x] << " ";
        }
        cout << "\n";
    }
}
Run Code Online (Sandbox Code Playgroud)

错误屏幕截图 错误屏幕截图

编辑:下面的固定代码。

void funcion1(int **matriz, int renglones, int columnas)
{
    for (int y = 0; y < renglones; y++)
    {
        for (int x = 0; x < columnas; x++)
        {
            matriz[y][x] = rand() % 10;
        }
    }
}

void funcion2(int **matriz, int renglones, int columnas)
{
    for (int y = 0; y < renglones; y++)
    {
        for (int x = 0; x < columnas; x++)
        {
            cout << matriz[y][x] << " ";
        }
        cout << "\n";
    }
}
Run Code Online (Sandbox Code Playgroud)

Pau*_*zie 5

您未能向链接器提供funcion1(int, int, int)funcion2(int, int, int)函数。您在 main() 程序中调用它们,但链接器找不到它。

不,这不会调用您的funcion1(int**, int, int)函数:

funcion1(**matriz, renglones, columnas);
Run Code Online (Sandbox Code Playgroud)

您正在int**两个级别取消引用,从而产生int. 与您的呼叫相同funcion2


调用 funcion1(**matriz, renglones, columnas)函数:

funcion1(matriz, renglones, columnas);
Run Code Online (Sandbox Code Playgroud)

同样的事情 funcion2(int **, int, int);

funcion2(matriz, renglones, columnas);
Run Code Online (Sandbox Code Playgroud)