apolukhin / Boost-Cookbook

Online examples from "Boost C++ Application Development Cookbook":
http://apolukhin.github.io/Boost-Cookbook/
Boost Software License 1.0
401 stars 108 forks source link

error: undefined reference to symbol 'pthread_condattr_setclock@@GLIBC_2.3.3' #4

Closed sildeag closed 5 years ago

sildeag commented 5 years ago

I have tried QMAKE_CXXFLAGS += -Wall -std=c++11 -pthread and LIBS += -lpthread and have been unable to resolve. Any ideas as to what I doing wrong?

apolukhin commented 5 years ago

Could you please provide more info: how are you compiling the examples, what versions fo qtcreator and compiler are you using, in what recipe that issue happened?

sildeag commented 5 years ago

glibc 2.3.3 is not used by Ubuntu 18.04 and is not on my system anywhere. I can recreate this issue opening project interupptions.pro with Qt Creator 4.5.2 and building without running. Default compiler is g++ version 7.3 (and clang 6.0 is also available.) Prior, I made sure Boost files were not installed anywhere on Ubuntu 18.04. I cloned Boost from github repository and built and installed in the prescribed manner. Github currently has the Boost source for version 1.69. Inside the Boost folder, sudo ./b2 -j4 toolset=gcc variant=release link=shared threading=multi address-model=64 cxxflags=-std=c++11 install and later I tried sudo ./b2 -j4 toolset=gcc-8.2 variant=release link=shared threading=multi address-model=64 cxxflags=-std=c++11 install to see if more current compiler version made a difference.

apolukhin commented 5 years ago

Looks like there's an issue in first_edition branch. Your toolkit probably uses single threaded configuration by deafult, while sources in the first_edition are unaware of such toolkits.

Try adding CONFIG += thread after this line https://github.com/apolukhin/Boost-Cookbook/blob/92930704c04655f4e52753f5c593358d226fc0cf/config.txt#L6

If that helps - please tell me, and I'll apply the fix.

sildeag commented 5 years ago

@apolukhin thanks. That was the most significant help. Other small changes required in some files ie. #include <iostream>, in some .pro files had to add -lboost_chrono, etc. probably all corrected in the second_edition. One can pin point the changes by building each subproject chapter or each subproject within a chapter.

apolukhin commented 5 years ago

I keep maintaining the first edition. So if you found and fixed some issues I'd appreciate a pull request :)

sildeag commented 5 years ago

@apolukhin okay I'll do that. I have forked the project. It will take a few days as I want to update the First Edition branch and the Second Edition branch. I haven't done that before.

sildeag commented 5 years ago

@apolukhin I've updated the sources with changes. Chapter 8 tuple_to_string (I didn't understand std::ref comment or how to fix) and Chapter 12 gil are outstanding issues. The travis GitHub checks seemed to fail because I am not using MSBuild but the code compiles cleanly.

apolukhin commented 5 years ago

Many thanks for the PR!

Fixed the above two examples and restored the CI. Builds are now passing.