LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
Email to...
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] threads compilation problem

[ILUG] threads compilation problem

Dave Airlie David.Airlie at ul.ie
Tue Mar 14 12:23:56 GMT 2000


-lpthread

Dave.

On Wed, 15 Mar 2000, john carter wrote:

> hi
> when i compile the file below using gcc abthread.c I get the following type of errors .
> 
> /tmp/cc4WfL0U.o(.text+0x6b) undefined reference to pthread_create
> /tmp/cc4WfL0U.o(.text+0xd7) undefined reference to pthread_join
> 
> 
> any ideas
> thanks john 
> 
> 
> heres the file
> 
> /* Creates two threads, one printing 10000 "a"s, the other printing
>    10000 "b"s.
>    Illustrates: thread creation, thread joining. */
> 
> #include <stddef.h>
> #include <stdio.h>
> #include <unistd.h>
> #include <pthread.h>
> 
> void * process(void * arg)
> {
>   int i;
>   fprintf(stderr, "Starting process %s\n", (char *) arg);
>   for (i = 0; i < 10000; i++) {
>     write(1, (char *) arg, 1);
>   }
>   return NULL;
> }
> 
> int main(void)
> {
>   int retcode;
>   pthread_t th_a, th_b;
>   void * retval;
> 
>   retcode = pthread_create(&th_a, NULL, process, (void *) "a");
>   if (retcode != 0) fprintf(stderr, "create a failed %d\n", retcode);
>   retcode = pthread_create(&th_b, NULL, process, (void *) "b");
>   if (retcode != 0) fprintf(stderr, "create b failed %d\n", retcode);
>   retcode = pthread_join(th_a, &retval);
>   if (retcode != 0) fprintf(stderr, "join a failed %d\n", retcode);
>   retcode = pthread_join(th_b, &retval);
>   if (retcode != 0) fprintf(stderr, "join b failed %d\n", retcode);
>   return 0;
> }
> 
> 
> 
>  for jokes check out www.csn.ul.ie/~mtbclub/john/jokes 
> _____________________________________
> 
> Get your free E-mail at http://www.ireland.com
> 
> 

-- 
------------ David Airlie, David.Airlie at ul.ie,airlied at skynet --------
Telecommunications Research Centre, ECE Dept, University of Limerick \
http://www.csn.ul.ie/~airlied	-- Telecommunications Researcher      \
--- TEL: +353-61-202695 -----------------------------------------------





More information about the ILUG mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


Maintained by the ILUG website team. The aim of Linux.ie is to support and help commercial and private users of Linux in Ireland. You can display ILUG news in your own webpages, read backend information to find out how. Networking services kindly provided by HEAnet, server kindly donated by Dell. Linux is a trademark of Linus Torvalds, used with permission. No penguins were harmed in the production or maintenance of this highly praised website. Looking for the Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!
RSS Version
Powered by Dell