build-your-own-redis icon indicating copy to clipboard operation
build-your-own-redis copied to clipboard

C++ build doesn't include pthread?

Open rohitpaulk opened this issue 1 year ago • 2 comments

For instance every time I try to submit stage 3 for Redis for C++, I keep getting "undefined reference to pthread_create". I have the header files and all of the dependencies installed, so I am just confused why this keeps happening when I try to push to origin master. Is there something completely obvious I am missing?

Thanks for @SamirOsAbdalla for reporting!

rohitpaulk avatar Dec 30 '23 19:12 rohitpaulk

Applying this change to CMakeLists.txt seems to fix the issue:

Screenshot 2023-12-30 at 19 50 23

Let's figure out why this builds locally but not on our build machines - maybe different C++ distributions include different libs by default?

rohitpaulk avatar Dec 30 '23 19:12 rohitpaulk

The CMakeLists change fixed the issue! As for why the issue arose in the first place, when I try to compile the Server file using g++(without the use of ./spawn_redis_server.sh) I also get the error of undefined reference to pthread_create. I have to add the flag -pthread in order to actually compile the program. Maybe this has something to do with it? This seems to correspond with the fix in the CMakeLists file which also has to link the pthread library.

SamirOsAbdalla avatar Jan 04 '24 00:01 SamirOsAbdalla

This is now fixed with the move to vcpkg!

rohitpaulk avatar Jun 18 '24 13:06 rohitpaulk