Code::Blocks Forums

User forums => Help => Topic started by: ruffride on March 28, 2016, 07:32:14 pm

Title: Change order of compiler flags
Post by: ruffride on March 28, 2016, 07:32:14 pm
Hi, i am having problems when compiling in CB, my program is using threads so i need to use -lpthread as last compiler flag, but CB puts this option

need this: g++ -Wall -pedantic -std=c++11 main.cpp -o main -lpthread
 have this:

Quote
-------------- Build: Debug in osy (compiler: GNU GCC Compiler)---------------

g++ -lpthread -pedantic -std=c++11 -Wall -g -Wall -fexceptions -lpthread -pedantic -std=c++11 -Wall  -c /home/samuel/Desktop/osy/main.cpp -o obj/Debug/main.o
g++  -o bin/Debug/osy obj/Debug/main.o   
obj/Debug/main.o: In function `prodArbitrageFunc(Info&)':
/home/samuel/Desktop/osy/main.cpp:118: undefined reference to `sem_wait'
/home/samuel/Desktop/osy/main.cpp:124: undefined reference to `sem_post'

i am using pultiple -lpthread flag above because i tried to put it everywhere i could :D
Title: Re: Change order of compiler flags
Post by: oBFusCATed on March 28, 2016, 09:11:22 pm
You're mixing the concepts a bit.
First if you had read the gcc manual you've known that the correct flag is -pthread and this one is both compiler and linker flag.
So you should add it to both compiler and linker flags in your project and it should be present in both links of the build log.