jermp / pthash

Fast and compact minimal perfect hash functions in C++.
MIT License
190 stars 25 forks source link

undefined reference to `pthread_create' #62

Closed jermp closed 2 months ago

jermp commented 4 months ago

Under Ubuntu 18.04.6 and gcc 7.5/11/13, I got an error undefined reference to pthread_create which is caused by target_compile_options(PTHASH INTERFACE -pthread) which does not seem to work. Re-adding the original set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread") works.

Why is that?

CC. @ByteHamster any ideas?

jermp commented 4 months ago

Did you also notice this @hmusta under gcc-12?

hmusta commented 4 months ago

My environment is gcc-12 with Ubuntu 20.04 and this doesn't seem to be an issue, target_compile_options(PTHASH INTERFACE -pthread) works fine

jermp commented 4 months ago

Thanks for confirming @hmusta! Perhaps it is an issue of cmake 3.25.

ByteHamster commented 4 months ago

Did you try a new, fresh build directory and used cmake from the command line? Maybe the old build directory or the IDE caches something. Using CMAKE_CXX_FLAGS is the old way to use cmake and causes problems because it applies the flag even to compilation units that don't use PTHash. (it even breaks the build when some target in the project uses a different compiler that doesn't understand the flag)

jermp commented 4 months ago

Actually yes, I did. I created some new build directories and executed cmake from there. But I could also try to re-clone the entire project from scratch...maybe maybe!

jermp commented 4 months ago

No, still getting the same errors: undefined pthread_create and pthread_join.

ByteHamster commented 4 months ago

Just for some of the targets (build, example, etc) or for all?

jermp commented 4 months ago

For all of them :/

jermp commented 2 months ago

Closing this as it seems a problem related to that specific server machine.