Witam! Mam problem z przekazaniem tablicy dwuwymiarowej do funkcji:
Pliki:
main.cpp:
#include <iostream>
#include "Biblioteka.h"
using namespace std;
Plansza p ={
{10,0,0,0,0,0,0,0,0,10},
{10,0,0,0,0,0,0,0,0,10},
{10,0,0,0,0,0,0,0,0,10},
{10,0,0,0,0,0,0,0,0,10},
{10,0,0,0,0,0,0,0,0,10},
{10,0,0,0,0,0,0,0,0,10},
{10,0,0,0,0,0,0,0,0,10},
{10,0,0,0,0,0,0,0,0,10},
{10,0,0,0,0,0,0,0,0,10},
{10,0,0,0,0,0,0,0,0,10},
{10,0,0,0,0,0,0,0,0,10},
{10,0,0,0,0,0,0,0,0,10},
{10,0,0,0,0,0,0,0,0,10},
{10,0,0,0,0,0,0,0,0,10},
{10,0,0,0,0,0,0,0,0,10},
{10,0,0,0,0,0,0,0,0,10},
{10,0,0,0,0,0,0,0,0,10},
{10,0,0,0,0,0,0,0,0,10},
{10,0,0,0,0,0,0,0,0,10},
{10,10,10,10,10,10,10,10,10,10},
};
int main()
{
Wyswietlanie(p);
system("pause");
return 0;
}
Biblioteka.h:
#pragma once
const int t = 10;
typedef int Plansza[2*t][t];
void Wyswietlanie(Plansza p);
View.cpp:
#include "Biblioteka.h"
#include <iostream>
using namespace std;
void Wyswietlanie(Plansza p)
{
for(int i = 0; i < 2*t; i++)
{
for(int j = 0; j < t; j++)
{
switch(p[i][j])
{
case 0:
cout<<" ";
break;
case 10:
cout<<"x";
break;
case 5:
cout<<"&";
break;
case 1:
cout<<"@";
break;
}
cout<<endl;
}
}
}
Powyzszy kod kompiluje sie bezproblemowo w srodowisku Windowsowym (Dev-C++ - TDM-GCC) natomiast pod Linuxem (g++) otrzymuje blad kompilacji:
CMakeFiles/Tetris_2.dir/main.cpp.o: In function `main':
/home/xkazeshinix/Desktop/Programowanie/c++/Tetris 2/main.cpp:32: undefined reference to `Wyswietlanie(int (*) [10])'
collect2: error: ld returned 1 exit status
CMakeFiles/Tetris_2.dir/build.make:94: recipe for target 'Tetris_2' failed
make[3]: *** [Tetris_2] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/Tetris_2.dir/all' failed
make[2]: *** [CMakeFiles/Tetris_2.dir/all] Error 2
CMakeFiles/Makefile2:79: recipe for target 'CMakeFiles/Tetris_2.dir/rule' failed
make[1]: *** [CMakeFiles/Tetris_2.dir/rule] Error 2
Makefile:118: recipe for target 'Tetris_2' failed
make: *** [Tetris_2] Error 2
Wie ktos jak moge rozwiazac ten problem pod Linuxem?
Z gory dziekuje za pomoc.
EDIT:
Dodalem sekcje plikow i bibliotek w kazdym z plikow.