Nowe posty

xx Problem ze sterownikami. (5)
2024-04-13, 21:25:16
xx Instalacja xfce4 (2)
2024-04-13, 16:20:17
xx Serie kompilacji bez instalacji dla “emerge” w Gentoo (2)
2024-04-08, 18:40:04
xx Plasma 6 w Neonie ssie trochę mniej ... (17)
2024-04-05, 10:03:46
xx Problem z Linux Lite po instalacji (3)
2024-04-03, 14:23:40
xx Jak właczyć num locka przy starcie systemu debian 12? (12)
2024-04-02, 17:43:54
xx Brak dźwieku w systemie. (5)
2024-04-02, 16:13:41
xx Dystrybucja pod HP Omen (7)
2024-03-29, 11:33:05
xx [Poradnik] Wyszukiwanie Sterowników (2)
2024-03-27, 21:08:23
xx Ile pingwinów? (1)
2024-03-27, 08:59:24

Autor Wątek: Wątki - symulacja sterowania skrzyżowaniem  (Przeczytany 8207 razy)

kiprom

  • Gość
Wątki - symulacja sterowania skrzyżowaniem
« dnia: 2011-12-22, 15:39:22 »
witam serdecznie. zastanawiam się jak opracować temat projektu
Napisz program, który będzie symulował programu sterowanie ruchem na „prostym”
skrzyżowaniu. Dla uproszczenia, należy przyjąć, że są tylko dwa kolory świateł:
czerwony, zielony. (UWAGA!!! Program powinien zostać zrealizowany przy pomocy
wątków) (Środowisko :Linux/Unix; tryb tekstowy: biblioteka Curses)
strukturę programu obsługującego wątki napisałem, ale zastanawiam się jak go zmodyfikować zgodnie z tematem projektu.
Kod: c [Zaznacz]
#include 
#include

static void * Doit ();

int main ()
{
pthread_t tid;
printf ("\\n Watek macierzysty ID=%d", pthread_self());
pthread_create(&tid, NULL, &Doit, NULL);
printf ("\\n Watek potomny zostal utworzony ID=%d", tid);
pthread_join (tid, NULL);
printf ("\\n Watek macierzysty ID=%d--> watek potomny zakonczony ID=%d", pthread_self(), tid);
printf ("\\n");
} /*main*/


static void * Doit ()
{
int i;
for (i=0; i<10; i++)
  {
   printf ("\\n Watek potomny ID=%d, i=%d", pthread_self(), i);
   sleep (1);
   }
  printf ("\\n Watek potomny ID=%d--> operacja zakonczenie", pthread_self());
}
jak zmodyfikować ten program??

--edit ZipoKing--
Poprawiłem błąd otrograficzny w tytule, bo aż po oczach razi :)

Ksanderon

  • Gość
Wątki - symulacja sterowania skrzyżowaniem
« Odpowiedź #1 dnia: 2011-12-23, 15:33:55 »
musisz opisać co to znaczy "sterowanie ruchem" tzn. skąd ten ruch nadchodzi jakie są warunki zdarzeń etc.

Czy np. wątek to pojazd, który chce przejechać bezpiecznie przez skrzyżowanie?
Jeśli tak to lepiej użyj wątków typu detached- i tak nie potrzebna ci zwracana wartość a eliminuje potrzebę joinowania, które mogło by być kłopotliwe gdybyś chciał to robić asynchronicznie(musiałbyś wtedy utworzyć wątek nadzorcy). Dodatkowo na pewno przydatne będą mutexy- jak i ile użyjesz to już kwestia pomysłu. Najprostszy sposób to chyba zablokowanie w "mainie" wszystkich kierunków a następnie odblokowywanie kolejno każdej trasy przy jednoczesnym blokowaniu starej.Dodatkowo dla całego skrzyżowania byłby mutex który byłby blokowany przez wątek aktualnie przejeżdżający co zapobiegłoby najeżdżaniu na siebie pojazdów z tego samego kierunku oraz wypadków przy zmianie światła

kiprom

  • Gość
Wątki - symulacja sterowania skrzyżowaniem
« Odpowiedź #2 dnia: 2011-12-23, 17:53:06 »
bardziej sprecyzować pytanie, to może inaczej mam dwa pomysły tylko nie wiem który będzie dobry do zadania.
1. 4 elementowa wiec myślałem nad kolorami (1,3 to kolor zielony a 2,4 to kolor czerwony) tyle żeby je na sztywno wstawić
2. Bardziej zaawansowane jak to na "prostym skrzyżowaniu" watek 1i3 (światło zielone) wykonują się natomiast 2i4 (światło czerwone) wykonują się po zakończeniu pracy wątku 1i3 a później na odwrót i zakończenie programu.
PS. Tylko jak to napisać :/ może macie jakiś szybki kurs programowania systemowego??

Ksanderon

  • Gość
Wątki - symulacja sterowania skrzyżowaniem
« Odpowiedź #3 dnia: 2011-12-23, 18:13:34 »
http://pl.wikibooks.org/wiki/POSIX_Threads

z twojej wypowiedzi nie wynika co mają robić wątki, po co i w jakich okolicznościach.

kiprom

  • Gość
Wątki - symulacja sterowania skrzyżowaniem
« Odpowiedź #4 dnia: 2012-01-15, 22:38:31 »
mam tu symulację skrzyżowania ale jest to oparte na procesach, co zmienić i gdzie aby działał na wątkach??

#include 
#include
#include
#include



void *Skrzyzowanie(){
//Obramowanie biale
{
attron(COLOR_PAIR(12));
int i,j,k;
for(i=1;i<20;i++)
{
for(j=0;j<65;j++)
mvprintw(i,j," ");

j=0;
}
i=0;
j=0;
refresh();}
//zielony trawnik
attron(COLOR_PAIR(1));
int i,j,k;
for(i=1;i<19;i++)
{
for(j=5;j<60;j++)
mvprintw(i,j," ");
j=0;
}
i=0;
j=0;
refresh();

/*poziomo*/
attron(COLOR_PAIR(4));
for(i=7;i<12;i++)
{
for(j=5;j<60;j++)
mvprintw(i,j," ");
j=0;
}
i=0;
j=0;
refresh();

attron(COLOR_PAIR(5));
/*poziomo linie*/
for(j=5;j<35;)
{
mvprintw(9,j,"-");
j=j+2;
}
for(j=35;j<60;)
{
mvprintw(9,j,"-");
j=j+2;
}
i=0;
j=0;
refresh();



attron(COLOR_PAIR(4));
/*pionowo*/
for(i=1;i<19;i++)
{
for(j=25;j<36;j++)
mvprintw(i,j," ");

j=21;
}
i=0;
j=0;
refresh();

attron(COLOR_PAIR(5));
/*pionowo linie*/
 

for(i=1;i<7;)
{
mvprintw(i,30,"|");
i=i+2;
}
for(i=12;i<20;)
{
mvprintw(i,30,"|");
i=i+2;
}
i=0;
j=0;
refresh();
return NULL;
}

void *Skrzyzowanie1() {

Skrzyzowanie();

attron(COLOR_PAIR(6));
mvprintw(10,18,"A");
mvprintw(4,26,"B");

/*pionowa start*/
attron(COLOR_PAIR(2));
mvprintw(5,19,"START");
refresh();

attron(COLOR_PAIR(2));

mvprintw(13,37,"START");
refresh();

/*poziomo stop*/
attron(COLOR_PAIR(3));
mvprintw(13,19,"STOP");
refresh();

attron(COLOR_PAIR(3));
mvprintw(5,37,"STOP");
refresh();
sleep(0);
refresh();

return NULL;
}

void *Samochod1(){

int c;
int a=3;
for(c=4; c<18; c++){
attron(COLOR_PAIR(6));
mvprintw(c,26,"B");


sleep(1);
attron(COLOR_PAIR(4));
mvprintw(a,26,"  ");
a++;

refresh();}
attroff( COLOR_PAIR(6));
attroff( COLOR_PAIR(4));
return NULL;
}
//----------------------------------------------------------------------------
void *Samochod2(){

int c;
int a=17;
for(c=18; c<58; c++)
{refresh();

c++;
attron(COLOR_PAIR(6));
mvprintw(10,c,"A");
sleep(1);
attron(COLOR_PAIR(4));
mvprintw(10,a,"  ");
a++;
a++;

}
attroff( COLOR_PAIR(6));
attroff( COLOR_PAIR(4));
return NULL;
}
//-------------------------------------------------------------------------------
void *Skrzyzowanie2(){

Skrzyzowanie();
attron(COLOR_PAIR(6));
mvprintw(10,18,"A");
mvprintw(4,26,"B");

//pionowo stop*/
attron(COLOR_PAIR(3));
mvprintw(5,20,"STOP");
refresh();

attron(COLOR_PAIR(3));
mvprintw(13,37,"STOP");
refresh();

/*pozioma start*/
attron(COLOR_PAIR(2));
mvprintw(13,19,"START");
refresh();

attron(COLOR_PAIR(2));
mvprintw(5,37,"START");
refresh();

return NULL;
}


int main(void) {


intrflush(stdscr,FALSE);

int x,y,Pid,i;

//
initscr();                        
getmaxyx(stdscr,y,x);

if ((y<20) || (x<60)) {
endwin();              
return 1;
}

start_color();
init_pair(1,COLOR_GREEN,COLOR_GREEN);
init_pair(2,COLOR_GREEN,COLOR_BLACK);
init_pair(3,COLOR_RED,COLOR_BLACK);
init_pair(4,COLOR_BLACK,COLOR_BLACK);
init_pair(5,COLOR_WHITE,COLOR_BLACK);
init_pair(6,COLOR_BLACK,COLOR_YELLOW);
init_pair(7,COLOR_MAGENTA,COLOR_WHITE);
init_pair(8,COLOR_BLACK,COLOR_CYAN);
init_pair(9,COLOR_WHITE,COLOR_BLACK);
init_pair(10,COLOR_BLACK,COLOR_RED);
init_pair(11,COLOR_RED,COLOR_MAGENTA);
init_pair(12,COLOR_WHITE,COLOR_WHITE);
attron(COLOR_PAIR(7));
printw("          Symulacja prostego skrzyzowania           ");
attron(COLOR_PAIR(9));
mvprintw(20,0,"Pid(%d) ", getpid(), Pid);
mvprintw(21,0,"Proces macierzysty(%d) ", getpid(), Pid);
refresh();
attron(COLOR_PAIR(2));
mvprintw(25,0,"Samochod B START");
refresh();
attron(COLOR_PAIR(3));
mvprintw(25,20,"Samochod A STOP");
refresh();

 if( (Pid=fork() ) ==0 ){
Skrzyzowanie();
for(i=0; i<2; i++){

Skrzyzowanie1();
Samochod1();
mvprintw(22,0,"Proces potmny(%d)",getpid());
{attron(COLOR_PAIR(2));
mvprintw(25,0,"Samochod A START");
refresh();
}
{attron(COLOR_PAIR(3));
mvprintw(25,20,"Samochod B STOP");
refresh();
}
refresh();
Skrzyzowanie2();
Samochod2();
refresh();
{attron(COLOR_PAIR(2));
mvprintw(25,0,"Samochod B START");
}
{attron(COLOR_PAIR(3));
mvprintw(25,20,"Samochod A STOP");
}

}
attron(COLOR_PAIR(10));
mvprintw(26,20," SYMULACJA ZAKOCZONA ");
attron(COLOR_PAIR(11));
mvprintw(28,0,"Proces potomny zakonczony(%d)",getpid());
refresh();
return 0;
}

wait(0);
attron(COLOR_PAIR(8));
mvprintw(26,0," Proces macierzysty zakonczony(%d)",getpid(), Pid);
refresh();
getch();
endwin();
return 0;
}

Ksanderon

  • Gość
Wątki - symulacja sterowania skrzyżowaniem
« Odpowiedź #5 dnia: 2012-01-16, 09:27:20 »
raczej słaby ten symulator to jedynie bezsensowna animacja 2 przypadków:)- i po co tu ktoś pcha wątki, procesy etc?

link który zamieściłem wcześniej na pewno da radę "sprostać" twoim wymaganiom.

kiprom

  • Gość
Wątki - symulacja sterowania skrzyżowaniem
« Odpowiedź #6 dnia: 2012-01-16, 09:35:52 »
no cóż to jest mój projekt na studia ;P a możesz chociaż powiedzieć w którym miejscu zmienić ?? bardzo proszę

Ksanderon

  • Gość
Wątki - symulacja sterowania skrzyżowaniem
« Odpowiedź #7 dnia: 2012-01-16, 17:19:36 »
och, jeśli sam to popełniłeś to wiesz, że proces powołujesz forkiem- i to tam będziesz chciał coś zmienić, choć z drugiej strony jest on tam tak konieczny jak w dowolnym innym miejscu tego programu, więc... właściwie wszędzie możesz wstawić sobie jakiś bezsensowny wątek na siłę, który będzie "odpowiedzialny" za zmianę koloru trawy co 1,76577 sekundy.

edit: sorry za sarkazm ale nie mogłem się powstrzymać. Sam jestem na pierwszym roku na pwr i rozumiem, że zadania bywają idiotyczne ale czasem można coś z siebie wykrzesać co przynajmniej sprawiało by pozory sensowności:D

kiprom

  • Gość
Wątki - symulacja sterowania skrzyżowaniem
« Odpowiedź #8 dnia: 2012-01-24, 18:14:43 »
co jest źle ;/

#include 
#include
#include
#include
#include
#include


void *Skrzyzowanie(){
//Obramowanie biale
{
attron(COLOR_PAIR(12));
int i,j,k;
for(i=1;i<20;i++)
{
for(j=0;j<65;j++)
mvprintw(i,j," ");

j=0;
}
i=0;
j=0;
refresh();}
//zielony trawnik
attron(COLOR_PAIR(1));
int i,j,k;
for(i=1;i<19;i++)
{
for(j=5;j<60;j++)
mvprintw(i,j," ");
j=0;
}
i=0;
j=0;
refresh();

/*poziomo*/
attron(COLOR_PAIR(4));
for(i=7;i<12;i++)
{
for(j=5;j<60;j++)
mvprintw(i,j," ");
j=0;
}
i=0;
j=0;
refresh();

attron(COLOR_PAIR(5));
/*poziomo linie*/
for(j=5;j<35;)
{
mvprintw(9,j,"-");
j=j+2;
}
for(j=35;j<60;)
{
mvprintw(9,j,"-");
j=j+2;
}
i=0;
j=0;
refresh();



attron(COLOR_PAIR(4));
/*pionowo*/
for(i=1;i<19;i++)
{
for(j=25;j<36;j++)
mvprintw(i,j," ");

j=21;
}
i=0;
j=0;
refresh();

attron(COLOR_PAIR(5));
/*pionowo linie*/
 

for(i=1;i<7;)
{
mvprintw(i,30,"|");
i=i+2;
}
for(i=12;i<20;)
{
mvprintw(i,30,"|");
i=i+2;
}
i=0;
j=0;
refresh();
return NULL;
}

void *Skrzyzowanie1() {

Skrzyzowanie();

attron(COLOR_PAIR(6));
mvprintw(10,18,"A");
mvprintw(4,26,"B");

/*pionowa start*/
attron(COLOR_PAIR(2));
mvprintw(5,19,"START");
refresh();

attron(COLOR_PAIR(2));

mvprintw(13,37,"START");
refresh();

/*poziomo stop*/
attron(COLOR_PAIR(3));
mvprintw(13,19,"STOP");
refresh();

attron(COLOR_PAIR(3));
mvprintw(5,37,"STOP");
refresh();
sleep(0);
refresh();

return NULL;
}

void *Samochod1(){

int c;
int a=3;
for(c=4; c<18; c++){
attron(COLOR_PAIR(6));
mvprintw(c,26,"B");


sleep(1);
attron(COLOR_PAIR(4));
mvprintw(a,26,"  ");
a++;

refresh();}
attroff( COLOR_PAIR(6));
attroff( COLOR_PAIR(4));
return NULL;
}
//----------------------------------------------------------------------------
void *Samochod2(){

int c;
int a=17;
for(c=18; c<58; c++)
{refresh();

c++;
attron(COLOR_PAIR(6));
mvprintw(10,c,"A");
sleep(1);
attron(COLOR_PAIR(4));
mvprintw(10,a,"  ");
a++;
a++;

}
attroff( COLOR_PAIR(6));
attroff( COLOR_PAIR(4));
return NULL;
}
//-------------------------------------------------------------------------------
void *Skrzyzowanie2(){

Skrzyzowanie();
attron(COLOR_PAIR(6));
mvprintw(10,18,"A");
mvprintw(4,26,"B");

//pionowo stop*/
attron(COLOR_PAIR(3));
mvprintw(5,20,"STOP");
refresh();

attron(COLOR_PAIR(3));
mvprintw(13,37,"STOP");
refresh();

/*pozioma start*/
attron(COLOR_PAIR(2));
mvprintw(13,19,"START");
refresh();

attron(COLOR_PAIR(2));
mvprintw(5,37,"START");
refresh();

return NULL;
}


static void * Doit ();

int main(void) {


intrflush(stdscr,FALSE);

int x,y;
pthread_t tid;

initscr();                        
getmaxyx(stdscr,y,x);

if ((y<20) || (x<60)) {
endwin();              
return 1;
}

start_color();
init_pair(1,COLOR_GREEN,COLOR_GREEN);
init_pair(2,COLOR_GREEN,COLOR_BLACK);
init_pair(3,COLOR_RED,COLOR_BLACK);
init_pair(4,COLOR_BLACK,COLOR_BLACK);
init_pair(5,COLOR_WHITE,COLOR_BLACK);
init_pair(6,COLOR_BLACK,COLOR_YELLOW);
init_pair(7,COLOR_MAGENTA,COLOR_WHITE);
init_pair(8,COLOR_BLACK,COLOR_CYAN);
init_pair(9,COLOR_WHITE,COLOR_BLACK);
init_pair(10,COLOR_BLACK,COLOR_RED);
init_pair(11,COLOR_RED,COLOR_MAGENTA);
init_pair(12,COLOR_WHITE,COLOR_WHITE);
attron(COLOR_PAIR(7));
printw("          Symulacja prostego skrzyzowania         ");
attron(COLOR_PAIR(9));
mvprintw(20,0,"Watek macierzysty tid (%d)", pthread_self());
pthread_create(&tid, NULL, &Doit, NULL);
mvprintw(21,0,"Watek potomny zostal utworzony tid (%d)", tid);
pthread_join (tid, NULL);
refresh();
attron(COLOR_PAIR(2));
mvprintw(25,0,"Samochod B START");
refresh();
attron(COLOR_PAIR(3));
mvprintw(25,20,"Samochod A STOP");
refresh();

attron(COLOR_PAIR(10));
mvprintw(26,20," SYMULACJA ZAKOCZONA ");
attron(COLOR_PAIR(11));
mvprintw(28,0,"Wątek potomny zakonczony(%d)",pthread_self());
refresh();
return 0;

attron(COLOR_PAIR(8));
mvprintw(26,0," Wątek macierzysty zakonczony(%d)",pthread_self(), tid);
refresh();
getch();
endwin();
return 0;
}

static void * Doit ()

int i;
Skrzyzowanie();
for(i=0; i<2; i++){

Skrzyzowanie1();
Samochod1();
mvprintw(22,0,"Watek potomny tid (%d) i=%d", pthread_self(), i);
{attron(COLOR_PAIR(2));
mvprintw(25,0,"Samochod A START");
refresh();
}
{attron(COLOR_PAIR(3));
mvprintw(25,20,"Samochod B STOP");
refresh();
}
refresh();
Skrzyzowanie2();
Samochod2();
refresh();
{attron(COLOR_PAIR(2));
mvprintw(25,0,"Samochod B START");
}
{attron(COLOR_PAIR(3));
mvprintw(25,20,"Samochod A STOP");
}

}

Ksanderon

  • Gość
Wątki - symulacja sterowania skrzyżowaniem
« Odpowiedź #9 dnia: 2012-01-24, 21:15:14 »
jak dla mnie wszystko. jeśli chodzi ci jedynie o skompilowanie tego i uruchomienie oraz "efekt(pomijając jego sens i implementację)" taki jak był z forkiem to zdecydowanie brakuje  pary {}.

kiprom

  • Gość
Wątki - symulacja sterowania skrzyżowaniem
« Odpowiedź #10 dnia: 2012-01-30, 16:09:02 »
podczas kompilacji programu (na procesach) wywala mi taki błąd ;/
/tmp/ccmJhwpo.o: In function `Skrzyzowanie':
aaa.c:(.text+0x7): undefined reference to `stdscr'
aaa.c:(.text+0x1f): undefined reference to `wattr_on'
aaa.c:(.text+0x4b): undefined reference to `mvprintw'
aaa.c:(.text+0x79): undefined reference to `stdscr'
aaa.c:(.text+0x81): undefined reference to `wrefresh'
aaa.c:(.text+0x86): undefined reference to `stdscr'
aaa.c:(.text+0x9e): undefined reference to `wattr_on'
aaa.c:(.text+0xca): undefined reference to `mvprintw'
aaa.c:(.text+0xf8): undefined reference to `stdscr'
aaa.c:(.text+0x100): undefined reference to `wrefresh'
aaa.c:(.text+0x105): undefined reference to `stdscr'
aaa.c:(.text+0x11d): undefined reference to `wattr_on'
aaa.c:(.text+0x149): undefined reference to `mvprintw'
aaa.c:(.text+0x177): undefined reference to `stdscr'
aaa.c:(.text+0x17f): undefined reference to `wrefresh'
aaa.c:(.text+0x184): undefined reference to `stdscr'
aaa.c:(.text+0x19c): undefined reference to `wattr_on'
aaa.c:(.text+0x1c0): undefined reference to `mvprintw'
aaa.c:(.text+0x1ee): undefined reference to `mvprintw'
aaa.c:(.text+0x20b): undefined reference to `stdscr'
aaa.c:(.text+0x213): undefined reference to `wrefresh'
aaa.c:(.text+0x218): undefined reference to `stdscr'
aaa.c:(.text+0x230): undefined reference to `wattr_on'
aaa.c:(.text+0x25c): undefined reference to `mvprintw'
aaa.c:(.text+0x28a): undefined reference to `stdscr'
aaa.c:(.text+0x292): undefined reference to `wrefresh'
aaa.c:(.text+0x297): undefined reference to `stdscr'
aaa.c:(.text+0x2af): undefined reference to `wattr_on'
aaa.c:(.text+0x2d3): undefined reference to `mvprintw'
aaa.c:(.text+0x301): undefined reference to `mvprintw'
aaa.c:(.text+0x31e): undefined reference to `stdscr'
aaa.c:(.text+0x326): undefined reference to `wrefresh'
/tmp/ccmJhwpo.o: In function `Skrzyzowanie1':
aaa.c:(.text+0x33d): undefined reference to `stdscr'
aaa.c:(.text+0x355): undefined reference to `wattr_on'
aaa.c:(.text+0x371): undefined reference to `mvprintw'
aaa.c:(.text+0x38d): undefined reference to `mvprintw'
aaa.c:(.text+0x392): undefined reference to `stdscr'
aaa.c:(.text+0x3aa): undefined reference to `wattr_on'
aaa.c:(.text+0x3c6): undefined reference to `mvprintw'
aaa.c:(.text+0x3cb): undefined reference to `stdscr'
aaa.c:(.text+0x3d3): undefined reference to `wrefresh'
aaa.c:(.text+0x3d8): undefined reference to `stdscr'
aaa.c:(.text+0x3f0): undefined reference to `wattr_on'
aaa.c:(.text+0x40c): undefined reference to `mvprintw'
aaa.c:(.text+0x411): undefined reference to `stdscr'
aaa.c:(.text+0x419): undefined reference to `wrefresh'
aaa.c:(.text+0x41e): undefined reference to `stdscr'
aaa.c:(.text+0x436): undefined reference to `wattr_on'
aaa.c:(.text+0x452): undefined reference to `mvprintw'
aaa.c:(.text+0x457): undefined reference to `stdscr'
aaa.c:(.text+0x45f): undefined reference to `wrefresh'
aaa.c:(.text+0x464): undefined reference to `stdscr'
aaa.c:(.text+0x47c): undefined reference to `wattr_on'
aaa.c:(.text+0x498): undefined reference to `mvprintw'
aaa.c:(.text+0x49d): undefined reference to `stdscr'
aaa.c:(.text+0x4a5): undefined reference to `wrefresh'
/tmp/ccmJhwpo.o: In function `Samochod1':
aaa.c:(.text+0x4ca): undefined reference to `stdscr'
aaa.c:(.text+0x4e2): undefined reference to `wattr_on'
aaa.c:(.text+0x4fd): undefined reference to `mvprintw'
aaa.c:(.text+0x50e): undefined reference to `stdscr'
aaa.c:(.text+0x526): undefined reference to `wattr_on'
aaa.c:(.text+0x541): undefined reference to `mvprintw'
aaa.c:(.text+0x54a): undefined reference to `stdscr'
aaa.c:(.text+0x552): undefined reference to `wrefresh'
aaa.c:(.text+0x565): undefined reference to `stdscr'
aaa.c:(.text+0x57d): undefined reference to `wattr_off'
aaa.c:(.text+0x582): undefined reference to `stdscr'
aaa.c:(.text+0x59a): undefined reference to `wattr_off'
/tmp/ccmJhwpo.o: In function `Samochod2':
aaa.c:(.text+0x5bf): undefined reference to `stdscr'
aaa.c:(.text+0x5c7): undefined reference to `wrefresh'
aaa.c:(.text+0x5d0): undefined reference to `stdscr'
aaa.c:(.text+0x5e8): undefined reference to `wattr_on'
aaa.c:(.text+0x603): undefined reference to `mvprintw'
aaa.c:(.text+0x608): undefined reference to `stdscr'
aaa.c:(.text+0x620): undefined reference to `wattr_on'
aaa.c:(.text+0x63b): undefined reference to `mvprintw'
aaa.c:(.text+0x656): undefined reference to `stdscr'
aaa.c:(.text+0x66e): undefined reference to `wattr_off'
aaa.c:(.text+0x673): undefined reference to `stdscr'
aaa.c:(.text+0x68b): undefined reference to `wattr_off'
/tmp/ccmJhwpo.o: In function `Skrzyzowanie2':
aaa.c:(.text+0x6a2): undefined reference to `stdscr'
aaa.c:(.text+0x6ba): undefined reference to `wattr_on'
aaa.c:(.text+0x6d6): undefined reference to `mvprintw'
aaa.c:(.text+0x6f2): undefined reference to `mvprintw'
aaa.c:(.text+0x6f7): undefined reference to `stdscr'
aaa.c:(.text+0x70f): undefined reference to `wattr_on'
aaa.c:(.text+0x72b): undefined reference to `mvprintw'
aaa.c:(.text+0x730): undefined reference to `stdscr'
aaa.c:(.text+0x738): undefined reference to `wrefresh'
aaa.c:(.text+0x73d): undefined reference to `stdscr'
aaa.c:(.text+0x755): undefined reference to `wattr_on'
aaa.c:(.text+0x771): undefined reference to `mvprintw'
aaa.c:(.text+0x776): undefined reference to `stdscr'
aaa.c:(.text+0x77e): undefined reference to `wrefresh'
aaa.c:(.text+0x783): undefined reference to `stdscr'
aaa.c:(.text+0x79b): undefined reference to `wattr_on'
aaa.c:(.text+0x7b7): undefined reference to `mvprintw'
aaa.c:(.text+0x7bc): undefined reference to `stdscr'
aaa.c:(.text+0x7c4): undefined reference to `wrefresh'
aaa.c:(.text+0x7c9): undefined reference to `stdscr'
aaa.c:(.text+0x7e1): undefined reference to `wattr_on'
aaa.c:(.text+0x7fd): undefined reference to `mvprintw'
aaa.c:(.text+0x802): undefined reference to `stdscr'
aaa.c:(.text+0x80a): undefined reference to `wrefresh'
/tmp/ccmJhwpo.o: In function `main':
aaa.c:(.text+0x81f): undefined reference to `stdscr'
aaa.c:(.text+0x82f): undefined reference to `intrflush'
aaa.c:(.text+0x834): undefined reference to `initscr'
aaa.c:(.text+0x839): undefined reference to `stdscr'
aaa.c:(.text+0x842): undefined reference to `stdscr'
aaa.c:(.text+0x85a): undefined reference to `stdscr'
aaa.c:(.text+0x863): undefined reference to `stdscr'
aaa.c:(.text+0x889): undefined reference to `endwin'
aaa.c:(.text+0x898): undefined reference to `start_color'
aaa.c:(.text+0x8b4): undefined reference to `init_pair'
aaa.c:(.text+0x8d0): undefined reference to `init_pair'
aaa.c:(.text+0x8ec): undefined reference to `init_pair'
aaa.c:(.text+0x908): undefined reference to `init_pair'
aaa.c:(.text+0x924): undefined reference to `init_pair'
/tmp/ccmJhwpo.o:aaa.c:(.text+0x940): more undefined references to `init_pair' follow
/tmp/ccmJhwpo.o: In function `main':
aaa.c:(.text+0x9ed): undefined reference to `stdscr'
aaa.c:(.text+0xa05): undefined reference to `wattr_on'
aaa.c:(.text+0xa11): undefined reference to `printw'
aaa.c:(.text+0xa16): undefined reference to `stdscr'
aaa.c:(.text+0xa2e): undefined reference to `wattr_on'
aaa.c:(.text+0xa5b): undefined reference to `mvprintw'
aaa.c:(.text+0xa88): undefined reference to `mvprintw'
aaa.c:(.text+0xa8d): undefined reference to `stdscr'
aaa.c:(.text+0xa95): undefined reference to `wrefresh'
aaa.c:(.text+0xa9a): undefined reference to `stdscr'
aaa.c:(.text+0xab2): undefined reference to `wattr_on'
aaa.c:(.text+0xace): undefined reference to `mvprintw'
aaa.c:(.text+0xad3): undefined reference to `stdscr'
aaa.c:(.text+0xadb): undefined reference to `wrefresh'
aaa.c:(.text+0xae0): undefined reference to `stdscr'
aaa.c:(.text+0xaf8): undefined reference to `wattr_on'
aaa.c:(.text+0xb14): undefined reference to `mvprintw'
aaa.c:(.text+0xb19): undefined reference to `stdscr'
aaa.c:(.text+0xb21): undefined reference to `wrefresh'
aaa.c:(.text+0xb76): undefined reference to `mvprintw'
aaa.c:(.text+0xb7b): undefined reference to `stdscr'
aaa.c:(.text+0xb93): undefined reference to `wattr_on'
aaa.c:(.text+0xbaf): undefined reference to `mvprintw'
aaa.c:(.text+0xbb4): undefined reference to `stdscr'
aaa.c:(.text+0xbbc): undefined reference to `wrefresh'
aaa.c:(.text+0xbc1): undefined reference to `stdscr'
aaa.c:(.text+0xbd9): undefined reference to `wattr_on'
aaa.c:(.text+0xbf5): undefined reference to `mvprintw'
aaa.c:(.text+0xbfa): undefined reference to `stdscr'
aaa.c:(.text+0xc02): undefined reference to `wrefresh'
aaa.c:(.text+0xc07): undefined reference to `stdscr'
aaa.c:(.text+0xc0f): undefined reference to `wrefresh'
aaa.c:(.text+0xc1e): undefined reference to `stdscr'
aaa.c:(.text+0xc26): undefined reference to `wrefresh'
aaa.c:(.text+0xc2b): undefined reference to `stdscr'
aaa.c:(.text+0xc43): undefined reference to `wattr_on'
aaa.c:(.text+0xc5f): undefined reference to `mvprintw'
aaa.c:(.text+0xc64): undefined reference to `stdscr'
aaa.c:(.text+0xc7c): undefined reference to `wattr_on'
aaa.c:(.text+0xc98): undefined reference to `mvprintw'
aaa.c:(.text+0xcad): undefined reference to `stdscr'
aaa.c:(.text+0xcc5): undefined reference to `wattr_on'
aaa.c:(.text+0xce1): undefined reference to `mvprintw'
aaa.c:(.text+0xce6): undefined reference to `stdscr'
aaa.c:(.text+0xcfe): undefined reference to `wattr_on'
aaa.c:(.text+0xd23): undefined reference to `mvprintw'
aaa.c:(.text+0xd28): undefined reference to `stdscr'
aaa.c:(.text+0xd30): undefined reference to `wrefresh'
aaa.c:(.text+0xd3c): undefined reference to `stdscr'
aaa.c:(.text+0xd54): undefined reference to `wattr_on'
aaa.c:(.text+0xd81): undefined reference to `mvprintw'
aaa.c:(.text+0xd86): undefined reference to `stdscr'
aaa.c:(.text+0xd8e): undefined reference to `wrefresh'
aaa.c:(.text+0xd93): undefined reference to `stdscr'
aaa.c:(.text+0xd9b): undefined reference to `wgetch'
aaa.c:(.text+0xda0): undefined reference to `endwin'
collect2: ld returned 1 exit status
co jest nie tak w ;/ wcześniej działało

Offline vanhelzing

  • Users
  • Prawie jak Guru
  • ****
  • Wiadomości: 314
    • Zobacz profil
Wątki - symulacja sterowania skrzyżowaniem
« Odpowiedź #11 dnia: 2012-01-30, 16:15:51 »
Wygląda na to, że nie dodałeś biblioteki ncurses do linkowania.

kiprom

  • Gość
Wątki - symulacja sterowania skrzyżowaniem
« Odpowiedź #12 dnia: 2012-01-30, 16:21:05 »
#include 
#include
#include
#include
takie mam zdeklarowane biblioteki

chmooreck

  • Gość
Wątki - symulacja sterowania skrzyżowaniem
« Odpowiedź #13 dnia: 2012-01-30, 17:18:26 »
Cytat: vanhelzing
Wygląda na to, że nie dodałeś biblioteki ncurses do linkowania.

kiprom

  • Gość
Wątki - symulacja sterowania skrzyżowaniem
« Odpowiedź #14 dnia: 2012-01-30, 17:18:58 »
a można precyzyjniej ? ;)