Gcc Error Undefined Reference To Pthread_create
Contents |
here for a quick overview of the site Help Center Detailed answers to
Undefined Reference To Pthread_create' Linux
any questions you might have Meta Discuss the workings and policies undefined reference to pthread_create' c++ of this site About Us Learn more about Stack Overflow the company Business Learn more
Undefined Reference To `pthread_create' Cmake
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 undefined reference to pthread_create code blocks Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up undefined reference to pthread_create in Linux up vote 160 down vote favorite 59 I picked up the following demo off the web from https://computing.llnl.gov/tutorials/pthreads/ #include 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 company Business Learn more about hiring developers or posting ads with us Unix & ubuntu install pthread Linux Questions Tags Users Badges Unanswered Ask Question _ Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it 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 http://stackoverflow.com/questions/1662909/undefined-reference-to-pthread-create-in-linux the top gcc can't link to pthread? up vote 12 down vote favorite 1 I have recently installed XUbuntu 11.10 64bit, but I am having problem compiling the most simple pthread example. Here is the code pthread_simple.c: #include 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 http://askubuntu.com/questions/568068/multithreading-in-codeblocks more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Ask Ubuntu Questions Tags Users Badges Unanswered Ask Question _ Ask Ubuntu is a question and answer site https://github.com/casacore/casacore/issues/104 for Ubuntu users and developers. Join them; it 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 undefined reference the top multithreading in codeblocks up vote 1 down vote favorite 1 I tried to implement multithreading using codeblocks in ubuntu. I typed the following program. void *myThreadFun(void *vargp) { sleep(1); printf("Printing hi from Thread \n"); return NULL; } int main() { pthread_t tid; printf("Before Thread\n"); pthread_create(&tid, NULL, myThreadFun, NULL); pthread_join(tid, NULL); printf("After Thread\n"); exit(0); } But I couldn't compile and run the program in codeblocks. I got the following undefined reference to error multithread.c undefined reference to 'pthread_create' multithread.c undefined reference to 'pthread_join' can someone help me out I had used the following header files in the code: pthread.h stdio.h stdlib.h code-blocks share|improve this question edited Jan 2 '15 at 15:15 Oli♦ 172k56434645 asked Jan 2 '15 at 15:05 mahesh 2315 add a comment| 3 Answers 3 active oldest votes up vote 2 down vote In Code::Blocks if you are using the GNU gcc compiler, you will probably need to add the -pthread compiler flag to both the compiler and linker options (under `Project --> Build options...) share|improve this answer answered Jan 2 '15 at 16:01 steeldriver 31.2k44474 Works fine in Code Blocks 13.12, Ubuntu 15.04 64 bit. –Anirban Ghosh Jun 24 '15 at 20:02 add a comment| up vote 2 down vote Don't forget to make sure that you installed the pthread librarys correctly. You can find it in the software center under "libpthread-stubs0-dev" or simply install by doing : sudo apt-get install libpthread-stubs0-dev. Also I didn't really understand at firt that you just have to type in -pthread manually... share|improve this answer edited Oct 8 '15 at 8:51 answered Oct 8 '15 at 8:46 Provo Cattivo 465 add a comment| up vote 0 down vote Please Sign in Pricing Blog Support Search GitHub This repository Watch 10 Star 22 Fork 35 casacore/casacore Code Issues 36 Pull requests 6 Projects 0 Wiki Pulse Graphs New issue CMake failure on Arch linux: pthread linking problem #104 Closed brentjens opened this Issue May 6, 2015 · 3 comments Projects None yet Labels None yet Milestone No milestone Assignees No one assigned 2 participants brentjens commented May 6, 2015 I can't build on an up-to-date arch linux I checked out commit e3eb912 cmake ../ succeeds, however cmake -DBUILD_PYTHON=ON -DPYTHON_EXECUTABLE=/usr/bin/python2 ../ produces: -- Configuring incomplete, errors occurred! See also "/home/brentjens/abs/casacore.git/build/CMakeFiles/CMakeOutput.log". See also "/home/brentjens/abs/casacore.git/build/CMakeFiles/CMakeError.log". Run Build Command:"/usr/bin/make" "cmTryCompileExec1433063075/fast"Undefined Reference To `pthread_create' C++11
Undefined Reference To Pthread_join
Determining if the pthread_create exist failed with the following output:
Change Dir: /home/brentjens/abs/casacore.git/build/CMakeFiles/CMakeTmp
/usr/bin/make -f CMakeFiles/cmTryCompileExec1433063075.dir/build.make CMakeFiles/cmTryCompileExec1433063075.dir/build
make[1]: Entering directory '/home/brentjens/abs/casacore.git/build/CMakeFiles/CMakeTmp'
/usr/bin/cmake -E cmake_progress_report /home/brentjens/abs/casacore.git/build/CMakeFiles/CMakeTmp/CMakeFiles 1
Building C object CMakeFiles/cmTryCompileExec1433063075.dir/CheckSymbolExists.c.o
/usr/bin/cc -fcx-fortran-rules -o CMakeFiles/cmTryCompileExec1433063075.dir/CheckSymbolExists.c.o -c /home/brentjens/abs/casacore.git/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c
Linking C executable cmTryCompileExec1433063075
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTry