Pthread Compile Error
Contents |
communities company blog Stack Exchange Inbox Reputation and Badges sign up log in tour help Tour Start here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the
How To Install Pthread Library In Ubuntu
company Business Learn more about hiring developers or posting ads with us Ask Ubuntu Questions gcc pthread compile Tags Users Badges Unanswered Ask Question _ Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it gcc pthread vs lpthread only takes a minute: Sign up Here's how it works: Anybody can ask a question Anybody can answer The best answers are voted up and rise to the top how to compile a c program that uses pthread.h?
Gcc Pthread Option
up vote 4 down vote favorite 1 I'm a beginner and I'm new to Ubuntu. I just installed it and want to run a C program. I have no idea what platform to use or where to write the code. I need to use pthread.h header file in the program. Can anyone help me? c share|improve this question edited Feb 14 '14 at 7:53 OrangeTux 2,88581949 asked Feb 14 '14 at 6:47 user248075 27112
Compile Pthread G++
possible duplicate of How to compile c & c++ programs? –Elder Geek Feb 19 '15 at 15:22 add a comment| 4 Answers 4 active oldest votes up vote 8 down vote Use: gcc MyProgram.c -o MyProgram -lpthread and dont forget to include the POSIX library in your code. It will compile your code. share|improve this answer edited Oct 6 '14 at 17:13 muru 69.5k12127177 answered Apr 5 '14 at 9:16 Parthiv Shah 10619 2 by default GCC does not include the pthread library. so you have to include the library using lpthread argument. –Parthiv Shah Apr 5 '14 at 9:30 Also note that in gcc-4.8 there is not -lpthread argument in man gcc. But there is a -pthread argument. Both work fine on Ubuntu 14.04 with gcc-4.8. –Elijah Lynn Aug 19 at 0:07 add a comment| up vote 0 down vote First thing you'll need in Ubuntu to compile C/C++ programs is installing GCC (Gnu Compiler Collection) which is part of build-essential package , do that by running: sudo apt-get install build-essential Then you can test if you have it installed by running gcc. If you you see error like Fatal error: file not provided (not sure exact error message, but should be something similar), that means you have compiler ready. And for editing your Code, you can use already available
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies undefined reference to pthread of this site About Us Learn more about Stack Overflow the company
How To Run Pthread Program In Linux
Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges how to run pthread program in linux terminal Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: http://askubuntu.com/questions/420722/how-to-compile-a-c-program-that-uses-pthread-h Sign up Pthreads C++ compilation error up vote 2 down vote favorite 1 I'm getting error "undefined reference to `pthread_attr_init'", even though that should be in pthread.h. This is in a UNIX environment that should be set up for Pthreads. Also, is a void* a good way to point to the current matrix? Here's my code, any ideas? #include
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss http://stackoverflow.com/questions/1662909/undefined-reference-to-pthread-create-in-linux the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. how to Join them; it only takes a minute: Sign up undefined reference to pthread_create in Linux up vote 162 down vote favorite 60 I picked up the following demo off the web from https://computing.llnl.gov/tutorials/pthreads/ #include