Pthread_create Linker Error
Contents |
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 undefined reference to pthread_create' ubuntu Learn more about Stack Overflow the company Business Learn more about hiring developers or
Undefined Reference To Pthread_create' C++
posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow undefined reference to `pthread_create' cmake Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up compile/link error using pthread up vote 3 down vote
Undefined Reference To Pthread_create Code Blocks
favorite I try to make a little program that sorts an array using threads but I can't get it to compile with the thread support. Error: sortieren.c:(.text+0xd7): undefined reference to `ptread_create' I used a make file for easy compiling but also on command line I can't get it to work. Basic code: #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 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 undefined reference to `pthread_create' c++11 you, helping each other. Join them; it only takes a minute: Sign up Undefined reference to 'pthread_create' — linker command option order (libraries before/after object files?) [duplicate] up vote 10 down vote favorite 6 This question already http://stackoverflow.com/questions/6332410/compile-link-error-using-pthread has an answer here: undefined reference to pthread_create in Linux 8 answers When I try to compile that, I receive a particular error. But, it's not possible because I use the right flag. In server.c there is the library pthread.h. So, how can I resolve my linking problem? I'm using Linux (Ubuntu). make gcc -c -Wall -Wunused -ansi -pedantic -ggdb -o Server1.o Server.c gcc -c -Wall -Wunused -ansi -pedantic -ggdb Util.c gcc -o Server1.exe -Wall http://stackoverflow.com/questions/9253200/undefined-reference-to-pthread-create-linker-command-option-order-libraries -Wunused -ansi -pedantic -ggdb -lpthread -lm Server1.o Util.o Server1.o: In function `main': /home/ruggero/ruggero_fine/Server.c:1002: undefined reference to `pthread_create' collect2: ld returned 1 exit status make: *** [Server1.exe] Errore 1 c ubuntu linker pthreads share|improve this question edited Mar 9 at 17:34 Jonathan Leffler 441k62513824 asked Feb 12 '12 at 22:09 rschirin 48831231 marked as duplicate by alkc Users with the c badge can single-handedly close c questions as duplicates and reopen them as needed. May 2 '15 at 17:10 This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question. 3 Did you try -pthread (without 'l')? See stackoverflow.com/questions/1662909/… –Zeta Feb 12 '12 at 22:13 1 The header is pthread.h; that is not the library, though. The library would have a name such as libpthread.so (at link time; and a name such as libpthread.so.1 at runtime). –Jonathan Leffler Feb 12 '12 at 22:20 add a comment| 2 Answers 2 active oldest votes up vote 30 down vote accepted List libraries after the object files When linking only object files and libraries, list the libraries after the object files: gcc -o Server1.exe -Wall -Wunused -ansi -pedantic -ggdb Server1.o Util.o -lpthread -lm When the linking command includes source files, list the source files and object files (if any) before the l here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies http://unix.stackexchange.com/questions/33396/gcc-cant-link-to-pthread of this site About Us Learn more about Stack Overflow the company Business http://www.cplusplus.com/forum/unices/151856/ Learn more about hiring developers or posting ads with us Unix & 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 undefined reference Here's how it works: Anybody can ask a question Anybody can answer The best answers are voted up and rise to 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 and clang. I have been tried four different solutions that I found on other forums but none seem to work. Here is the code: 1Makefile Pthread Example
Ubuntu Install Pthread
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
cmake_minimum_required(VERSION 2.6) SET (CMAKE_C_COMPILER "/usr/bin/clang") SET (CMAKE_C_FLAGS "-Wall -std=c++11 -Werror") SET (CMAKE_C_FLAGS_DEBUG "-g") SET (CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG") SET (CMAKE_C_FLAGS_RELEASE "-O4 -DNDEBUG") SET (CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g") SET (CMAKE_CXX_COMPILER "/usr/bin/clang++") SET (CMAKE_CXX_FLAGS "-Wall -std=c++11 -Werror") SET (CMAKE_CXX_FLAGS_DEBUG "-g") SET (CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG") SET (CMAKE_CXX_FLAGS_RELEASE "-O4 -DNDEBUG") SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g") SET (CMAKE_AR "/usr/bin/llvm-ar") SET (CMAKE_LINKER "/usr/bin/llvm-ld") SET (CMAKE_NM "/usr/bin/llvm-nm") SET (CMAKE_OBJDUMP "/usr/bin/llvm-objdump") SET (CMAKE_RANLIB "/usr/bin/llvm-ranlib") SET (LLVM_ENABLE_THREADS "yes") project(threading) add_executable(threading main.cpp) TARGET_LINK_LIBRARIES(pthread) Thanks Sorry here is the error: 1
2
3
4
5
6
7
8
9
CMakeFiles/threading.dir/main.cpp.o: In function `main': /home/arortell/Development/P