News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

Change order of compiler flags

Started by ruffride, March 28, 2016, 07:32:14 PM

Previous topic - Next topic

ruffride

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

oBFusCATed

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.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]