Code::Blocks Forums

User forums => Help => Topic started by: suxotova on March 11, 2022, 04:11:40 am

Title: compiler flags issue
Post by: suxotova on March 11, 2022, 04:11:40 am
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:

Code
-------------- 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   [url]https://sexcams.fans/[/url]
obj/Debug/main.o: In function `prodArbitrageFunc(Info&)': [url]https://freelivesexcams.me/[/url] , [url]https://freecams.name/[/url]
/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  :)

https://sexcams.fans/ (https://sexcams.fans/)
https://freelivesexcams.me/ (https://freelivesexcams.me/) , https://freecams.name/ (https://freecams.name/)
Title: Re: compiler flags issue
Post by: stahta01 on March 11, 2022, 05:32:44 am
Did you try putting the library in the library list in your CB project?

https://wiki.codeblocks.org/index.php/FAQ-Compiling_(general)#Q:_I_would_like_to_compile_a_project_using_some_non-standard_libraries._How_can_I_indicate_to_CodeBlocks_that_these_libraries_and_include_files_exist.3F (https://wiki.codeblocks.org/index.php/FAQ-Compiling_(general)#Q:_I_would_like_to_compile_a_project_using_some_non-standard_libraries._How_can_I_indicate_to_CodeBlocks_that_these_libraries_and_include_files_exist.3F)

Tim S.
Title: Re: compiler flags issue
Post by: osdt on March 11, 2022, 05:52:17 am
Compilation (source file) and linking (executable) are two separate steps.

You'll need to set -pthread within 'Compiler options' and -lpthread within 'Linker options'.