Open Mellowchan opened 2 years ago
/usr/bin/cc -DCHECK_FUNCTION_EXISTS=pthread_create CMakeFiles/cmTC_dbb4b.dir/CheckFunctionExists.c.o -o cmTC_dbb4b -lpthreads
Huh, that's weird. The library is called pthread
, and I found some discussion about how FreeBSD apparently wants you to invoke the compiler with -pthread
instead of explicitly linking to -lpthread
. I was hoping that cmake automagically takes care of things like these, but apparently not.
Wildly guess that these people happen to solve the same issue, I would hope that the following would fix the issue:
if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
target_link_libraries (libhighs "pthread")
endif()
I don't have a FreeBSD installation available, and I can't easily test it. Also, I have no experience with any BSD, I'm sorry if you have to test around with this a bit.
I would assume that it goes into line 38, right before link_directories(${Purple_LIBRARY_DIRS})
(before it, not replacing it).
Let me know if that works. If it does, please make a PR! :)
Thank you for your quick answer.
I've tried adding those lines although libhighs is not the library we are compiling now.
I've tried to change it to tdlib-purple
, telegram-tdlib
and telegram-purple
but sadly neither of those works for me.
It might be probably trivial but the current error with those lines is:
CMake Error at CMakeLists.txt:40 (target_link_libraries):
Cannot specify link libraries for target "tdlib-purple" which is not
built by this project.
You're right, I forgot to replace libhighs
with telegram-tdlib
, sorry ^^
Hmm, then apparently cmake runs into this issue before even trying to link the plugin.
I'm not really sure what the "correct" solution is, or how cmake wants to be treated. As a workaround, I think the following might work, although it feels a bit brutish:
add_link_options("-pthread")
Again, you might have to try around a bit, I can't try this out on FreeBSD. The idea behind this is to inject a linker option, and thus make the test believe that pthread is available without even linking against any library. Your logs indicate that cmake considers this possible, and checks this first.
So update. I've tried adding options / setting global variables from following theads https://stackoverflow.com/questions/28029195/how-to-let-cmake-use-pthread-instead-of-lpthread https://stackoverflow.com/questions/1620918/cmake-and-libpthread https://stackoverflow.com/questions/54189656/what-is-the-proper-use-of-cmake-findthreads-with-modern-c
But no luck and the problem still persist.
If i understand correctly. On linux to use -lpthreads
you need to install libboost and there should be probably default pthread.h too.
May I ask you please if you could try to compile this library (i assume you're on linux) with -pthreads ?
Hello,
i'm trying to port newest telegram libpurple to freebsd but i'm currently having problems with pthreads.h library.
the library exists on the system
here is my CMakeError.log