Symbols not found in architecture + linker command failed with exit code 1

30,669

You failed to supply the funcion1(int, int, int) and funcion2(int, int, int) functions to the linker. You're calling them in your main() program, but the linker can't find it.

And no, this does not call your funcion1(int**, int, int) function:

funcion1(**matriz, renglones, columnas);

You are dereferencing the int** on two levels, thus yielding an int. Same thing with your call to funcion2.


To call the funcion1(**matriz, renglones, columnas) function:

funcion1(matriz, renglones, columnas);

Same thing with funcion2(int **, int, int);

funcion2(matriz, renglones, columnas);
Share:
30,669
Alonso Iturbe
Author by

Alonso Iturbe

Updated on January 30, 2020

Comments

  • Alonso Iturbe
    Alonso Iturbe over 4 years

    I have been cracking my head over this one. I've searched all over and all I seem to find are issues with the same error messages but involving either building complete iphone apps or dealing with header files, all sorts of stuff.

    I was just writing a simple C++ program, no header files except the typical iostream, stdlib.h and time.h. This is for a very simple college assignment, but I can't keep working because Xcode gives me this error that has nothing to do with the actual code (based on what I've read). I haven't messed with anything other than the actual .cpp file, I don't even know how I could've messed this up. I've done multiple assignments the same way and have never run into this issue before.

    Current code:

    #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";
        }
    }
    

    Screenshot of error screen Screenshot of error screen

    EDIT: Fixed code below.

    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";
        }
    }
    
  • Alonso Iturbe
    Alonso Iturbe over 9 years
    Thank you! That got rid of the error messages, but now these two lines give me the error "Subscripted value is not and array, pointer or vector" matriz[y][x] = rand() % 10; and cout << matriz[y][x] << " ";
  • PaulMcKenzie
    PaulMcKenzie over 9 years
    Exactly which function were you trying to implement? funcion1(int**, int, int) or funcion1(int, int, int)? If it's the second one, and you kept the code the same in the function body, then of course you get an error, since the first parmeter is a plain-old int.
  • Alonso Iturbe
    Alonso Iturbe over 9 years
    Oh, nevermind, it was some other error, something to do with me accesing data i didn't have persission to. Thank you so much!