Re: work with threads
March 2, 2012 at 9:35 am
#3725
Antonio Muñoz
Participant
This is the program code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
unsigned short c_timer;
void *thread_function(void *arg)
{
while(c_timer)
{
sleep(1);
c_timer–;
}
return NULL;
}
int main (void)
{
pthread_t mythread;
c_timer = 20;
if ( pthread_create( &mythread, NULL, thread_function, NULL) )
{
printf(“Error.”);
abort();
}
printf(“20 sec. for exit”);
while(c_timer);
printf(“Goodbye”);
}
to build:
– source env-oe.sh
– export PATH=${OETREE}/build/tmp/sysroots/i686-linux/usr/armv5te/bin:$PATH
– arm-corecdp-linux-gnueabi-gcc -o test test.c
This is the result of the build:
/tmp/cc5EYUVc.o: In function `main’:
test.c:(.text+0x8c): undefined reference to `pthread_create’
collect2: ld returned 1 exit status
Thanks