bombtrash bombtrash - 2 months ago 12x
C Question

How to add flags to compiler in code blocks?

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


In codeblocks 16.01, you can specify the library you want to link (in this case via Settings > Compiler... > Linker Settings > Add

Then you need to add the location of via locate

In this case, you may also need to specify -D_REENTRANT compiler flag to tell gcc about necessary headers for thread usage.