I am not sure if the question is framed correctly. But I am using code blocks on a windows machine. I want to use gcc -o myfile myfile.c -lpthread
. But in my code blocks I don't have this -lpthread flag(is that called a flag?). So where do I need to add this in code blocks so that when I click build, it will simply call gcc -o myfile myfile.c -lpthread
.
Asked
Active
Viewed 1,535 times
1

Daniel A. White
- 187,200
- 47
- 362
- 445

MikeJoe
- 101
- 1
- 2
- 12
2 Answers
1
-lpthread is a flag to the linker saying to include the library pthread (POSIX threads). I'm not particularly good with code blocks but in the main settings you should be able to find options for configuring the compiler or linker. You need to add the library "pthread" there.
Take a look at this possible duplicate: How do I link to a library with Code::Blocks?
0
In codeblocks 16.01, you can specify the library you want to link (in this case libpthread.so) via Settings > Compiler... > Linker Settings > Add
Then you need to add the location of libpthread.so
via locate libpthread.so
In this case, you may also need to specify -D_REENTRANT
compiler flag to tell gcc
about necessary headers for thread usage.

artm
- 17,291
- 6
- 38
- 54