Author Topic: Change order of compiler flags  (Read 2426 times)

ruffride

  • Guest
Change order of compiler flags
« 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

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Change order of compiler flags
« Reply #1 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.
(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!]