Alright, so i changed my code to:

Code:

#include "matrix.h"
matrix create_empty(int rdim, int cdim)
{
matrix* new_matrix;
new_matrix = malloc(sizeof(matrix));
new_matrix -> rowdim = rdim;
new_matrix -> coldim = cdim;
new_matrix -> element = malloc((rdim*cdim) * sizeof(double));
return *new_matrix;
}
matrix create_initval(int rdim, int cdim, double* values)
{
int i, j;
matrix* new_matrix;
new_matrix = malloc(sizeof(matrix));
new_matrix -> rowdim = rdim;
new_matrix -> coldim = cdim;
new_matrix -> element = malloc((rdim*cdim) * sizeof(double));
for (i=0; i<cdim; i++)
{
for(j=0; j<rdim; j++)
new_matrix -> element[j * rdim + i] = values[j * rdim + i];
{
return *new_matrix;
}
void destroy(matrix a)
{
free(&a.element);
}
void matrix_print(matrix a)
{
int i, j;
printf("\n");
for (i=0; i<a.coldim; i++)
{
for(j=0; i<a.rowdim; j++)
{
printf(" %f ", a.element[j * rdim + i]);
}
}
}
}
}

I also created a test file that looks like:

Code:

#include "matrix.h"
int main()
{
double one[2][3] = {
{1,2,3},
{4,5,6}
};
matrix m_one;
m_one = create_initval(2, 3, *one);
matrix_print(m_one);
return 0;
}

but when i compile, i get:

/tmp/ccgEP8z2.o: In function `main':

test.c.text+0x7d): undefined reference to `matrix_print'

collect2: ld returned 1 exit status