This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: POSIX layer and pthread:Unable to make the application


On 04/11/2012 07:38 PM, Fabrizio Carrai wrote:

Hi,

The problem is that I dont have the <cyg/fileio/limits.h> header in my install tree also the <cyg/posix/pthread.h> header
and I don't know why the confgtool did not generate these file when I build the library, Is it a problem of version of the configtool or what??
Hi,
also this seems a problem on the eCos library configuration generated
with the configtool.
I used the configuration I suggested in a previous post (and that you
adopted!) and I'm able to compile your example. Some warnings, but no
errors.

The inclusion tree is the following:
"pthread.h"
"pkgconf/isoinfra.h"
"cyg/posix/pthread.h"

The latter include the declarations that you miss. Please, check it.
Your "standard_Posix" configuration should be good.

Fabrizio

Il giorno 11 aprile 2012 16:12, medamine<medamine.ecos@gmail.com> ha scritto:

Hi every one,

I use
Hardware: ST STM3210E EVAL board
Packages: posix
in the section:POSIX threads

POSIX pthread implementation header Enabled=True Value=0
POSIX mutex/cond var implementation header Enabled=True Value=0

and I got the pthread.h :

#ifndef CYGONCE_ISO_PTHREAD_H
#define CYGONCE_ISO_PTHREAD_H
/*===========================================
//
// pthread.h
//
// POSIX pthread functions
//
//===========================================

/* CONFIGURATION */

#include<pkgconf/isoinfra.h> /* Configuration header */

/* INCLUDES */

#ifdef CYGINT_ISO_PTHREAD_IMPL
# ifdef CYGBLD_ISO_PTHREAD_IMPL_HEADER
# include CYGBLD_ISO_PTHREAD_IMPL_HEADER
# endif
#endif

#ifdef CYGINT_ISO_PTHREAD_MUTEX
# ifdef CYGBLD_ISO_PTHREAD_MUTEX_HEADER
# include CYGBLD_ISO_PTHREAD_MUTEX_HEADER
# endif
#endif

#endif /* CYGONCE_ISO_PTHREAD_H multiple inclusion protection */

/* EOF pthread.h */

After that, i wrote this application using thread

#include<pthread.h>
#include<stdio.h>
#define NUM_THREADS 5

void *PrintHello(void *threadid)
{
long tid;
tid = (long)threadid;
printf("Hello World! It's me, thread #%ld!\n", tid);
pthread_exit(NULL);
}

int main (int argc, char *argv[])
{
pthread_t threads[NUM_THREADS];
int rc;
long t;
for(t=0; t<NUM_THREADS; t++){
printf("In main: creating thread %ld\n", t);
rc = pthread_create(&threads[t], NULL, PrintHello, (void *)t);
if (rc){
printf("ERROR; return code from pthread_create() is %d\n", rc);
exit(-1);
}
}

/* Last thing that main() should do */
pthread_exit(NULL);
}

but when i build the application withe eCos library, i got these errors

/STM3240G/fork$ make hello
arm-eabi-gcc -c -o hello.o -I/home/st/config/standard_Posix_install/include -Wall -Wpointer-arith -Wstrict-prototypes -Wundef -Woverloaded-virtual -Wno-write-strings -mcpu=cortex-m3 -mthumb -g -O2 -ffunction-sections -fdata-sections -fno-rtti -fno-exceptions hello.c
cc1: warning: command line option "-Woverloaded-virtual" is valid for C++/ObjC++ but not for C
cc1: warning: command line option "-fno-rtti" is valid for C++/ObjC++ but not for C
hello.c: In function ‘PrintHello’:
hello.c:10: warning: implicit declaration of function ‘pthread_exit’
hello.c: In function ‘main’:
hello.c:15: error: ‘pthread_t’ undeclared (first use in this function)
hello.c:15: error: (Each undeclared identifier is reported only once
hello.c:15: error: for each function it appears in.)
hello.c:15: error: expected ‘;’ before ‘threads’
hello.c:20: warning: implicit declaration of function ‘pthread_create’
hello.c:20: error: ‘threads’ undeclared (first use in this function)
hello.c:23: warning: implicit declaration of function ‘exit’
hello.c:23: warning: incompatible implicit declaration of built-in function ‘exit’
make: *** [hello.o] Error 1

First view is that the thread functions doesn't exist in the header thread.h, the configtool generate uncompleted headers,

Please i need your help.

Thanks a lot.



--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss



--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]