mujx / nheko

No longer maintained - Desktop client for the Matrix protocol (active fork https://github.com/Nheko-Reborn)
GNU General Public License v3.0
394 stars 65 forks source link

Build fails with: undefined reference to `pthread_create' #373

Closed dset0x closed 6 years ago

dset0x commented 6 years ago

System:

Steps to reproduce

cmake .

Logs

Build type set to 'Debug'
-- Version: 0.5.0-96a2c61
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
LMDBXX_INCLUDE_DIR
   used as include directory in directory /home/user/src/nheko
   <repeated>
TWEENY_INCLUDE_DIR
   used as include directory in directory /home/user/src/nheko
   <repeated>

-- Configuring incomplete, errors occurred!
See also "/home/user/src/nheko/CMakeFiles/CMakeOutput.log".
See also "/home/user/src/nheko/CMakeFiles/CMakeError.log".
Determining if the pthread_create exist failed with the following output:
Change Dir: /home/user/src/nheko/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/gmake" "cmTC_04235/fast"
/usr/bin/gmake -f CMakeFiles/cmTC_04235.dir/build.make CMakeFiles/cmTC_04235.dir/build
gmake[1]: Entering directory '/home/user/src/nheko/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_04235.dir/CheckSymbolExists.c.o
/usr/bin/cc    -o CMakeFiles/cmTC_04235.dir/CheckSymbolExists.c.o   -c /home/user/src/nheko/CMakeFiles/CMakeTmp/CheckSymbolExists.c
Linking C executable cmTC_04235
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_04235.dir/link.txt --verbose=1
/usr/bin/cc      -rdynamic CMakeFiles/cmTC_04235.dir/CheckSymbolExists.c.o  -o cmTC_04235 
CMakeFiles/cmTC_04235.dir/CheckSymbolExists.c.o: In function `main':
CheckSymbolExists.c:(.text+0x1b): undefined reference to `pthread_create'
collect2: error: ld returned 1 exit status
gmake[1]: *** [CMakeFiles/cmTC_04235.dir/build.make:98: cmTC_04235] Error 1
gmake[1]: Leaving directory '/home/user/src/nheko/CMakeFiles/CMakeTmp'
gmake: *** [Makefile:126: cmTC_04235/fast] Error 2

File /home/user/src/nheko/CMakeFiles/CMakeTmp/CheckSymbolExists.c:
/* */
#include <pthread.h>

int main(int argc, char** argv)
{
  (void)argv;
#ifndef pthread_create
  return ((int*)(&pthread_create))[argc];
#else
  (void)argc;
  return 0;
#endif
}
mujx commented 6 years ago

Did you follow the instructions from https://github.com/mujx/nheko#building? Also what is your cmake version?

dset0x commented 6 years ago

@mujx Woops. I did not. Unfortunately it doesn't seem to make a difference:

cmake -Hdeps -B.deps -DUSE_BUNDLED_BOOST=OFF DUSE_BUNDLED_SPDLOG=OFF .            # mind you I had to add a `.` here.
Build type set to 'Release'
-- Version: 0.5.0-96a2c61
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
LMDBXX_INCLUDE_DIR
   used as include directory in directory /home/user/src/nheko
   used as include directory in directory /home/user/src/nheko
   used as include directory in directory /home/user/src/nheko
   used as include directory in directory /home/user/src/nheko
   used as include directory in directory /home/user/src/nheko
   used as include directory in directory /home/user/src/nheko
   used as include directory in directory /home/user/src/nheko
   used as include directory in directory /home/user/src/nheko
   used as include directory in directory /home/user/src/nheko
TWEENY_INCLUDE_DIR
   used as include directory in directory /home/user/src/nheko
   used as include directory in directory /home/user/src/nheko
   used as include directory in directory /home/user/src/nheko
   used as include directory in directory /home/user/src/nheko
   used as include directory in directory /home/user/src/nheko
   used as include directory in directory /home/user/src/nheko
   used as include directory in directory /home/user/src/nheko
   used as include directory in directory /home/user/src/nheko
   used as include directory in directory /home/user/src/nheko

-- Configuring incomplete, errors occurred!
See also "/home/user/src/nheko/CMakeFiles/CMakeOutput.log".
See also "/home/user/src/nheko/CMakeFiles/CMakeError.log".

Same pthread issue in the CMakeError.log file.

I also tried switching the *BUNDLED* directives on and off.

mujx commented 6 years ago

There is an omission regarding the INCLUDE_DIR flags.

Could you try the following

rm -rf .deps
rm -rf build

# Installing dependencies
cmake -Hdeps -B.deps -DUSE_BUNDLED_BOOST=OFF
cmake --build .deps --config Release

# Build nheko
cmake -H. -Bbuild \
  -DLMDBXX_INCLUDE_DIR=.deps/usr/include \
  -DTWEENY_INCLUDE_DIR=.deps/usr/include
cmake --build build --config Release
dset0x commented 6 years ago

There was a bit of whining during cmake --build .deps --config Release:

-- Found sodium: /usr/lib/libsodium.so  
CMake Warning at /usr/share/cmake/Modules/FindBoost.cmake:786 (message):
  New Boost version may have incorrect or missing dependencies and imported
  targets
Call Stack (most recent call first):
  /usr/share/cmake/Modules/FindBoost.cmake:892 (_Boost_COMPONENT_DEPENDENCIES)
  /usr/share/cmake/Modules/FindBoost.cmake:1523 (_Boost_MISSING_DEPENDENCIES)
  CMakeLists.txt:58 (find_package)

CMake Warning at /usr/share/cmake/Modules/FindBoost.cmake:786 (message):
  New Boost version may have incorrect or missing dependencies and imported
  targets
Call Stack (most recent call first):
  /usr/share/cmake/Modules/FindBoost.cmake:892 (_Boost_COMPONENT_DEPENDENCIES)
  /usr/share/cmake/Modules/FindBoost.cmake:1523 (_Boost_MISSING_DEPENDENCIES)
  CMakeLists.txt:58 (find_package)

CMake Warning at /usr/share/cmake/Modules/FindBoost.cmake:786 (message):
  New Boost version may have incorrect or missing dependencies and imported
  targets
Call Stack (most recent call first):
  /usr/share/cmake/Modules/FindBoost.cmake:892 (_Boost_COMPONENT_DEPENDENCIES)
  /usr/share/cmake/Modules/FindBoost.cmake:1523 (_Boost_MISSING_DEPENDENCIES)
  CMakeLists.txt:58 (find_package)

CMake Warning at /usr/share/cmake/Modules/FindBoost.cmake:786 (message):
  New Boost version may have incorrect or missing dependencies and imported
  targets
Call Stack (most recent call first):
  /usr/share/cmake/Modules/FindBoost.cmake:892 (_Boost_COMPONENT_DEPENDENCIES)
  /usr/share/cmake/Modules/FindBoost.cmake:1523 (_Boost_MISSING_DEPENDENCIES)
  CMakeLists.txt:58 (find_package)

CMake Warning at /usr/share/cmake/Modules/FindBoost.cmake:786 (message):
  New Boost version may have incorrect or missing dependencies and imported
  targets
Call Stack (most recent call first):
  /usr/share/cmake/Modules/FindBoost.cmake:892 (_Boost_COMPONENT_DEPENDENCIES)
  /usr/share/cmake/Modules/FindBoost.cmake:1523 (_Boost_MISSING_DEPENDENCIES)
  CMakeLists.txt:58 (find_package)

CMake Warning at /usr/share/cmake/Modules/FindBoost.cmake:786 (message):
  New Boost version may have incorrect or missing dependencies and imported
  targets
Call Stack (most recent call first):
  /usr/share/cmake/Modules/FindBoost.cmake:892 (_Boost_COMPONENT_DEPENDENCIES)
  /usr/share/cmake/Modules/FindBoost.cmake:1523 (_Boost_MISSING_DEPENDENCIES)
  CMakeLists.txt:58 (find_package)

CMake Warning at /usr/share/cmake/Modules/FindBoost.cmake:786 (message):
  New Boost version may have incorrect or missing dependencies and imported
  targets
Call Stack (most recent call first):
  /usr/share/cmake/Modules/FindBoost.cmake:892 (_Boost_COMPONENT_DEPENDENCIES)
  /usr/share/cmake/Modules/FindBoost.cmake:1523 (_Boost_MISSING_DEPENDENCIES)
  CMakeLists.txt:58 (find_package)

CMake Warning at /usr/share/cmake/Modules/FindBoost.cmake:786 (message):
  New Boost version may have incorrect or missing dependencies and imported
  targets
Call Stack (most recent call first):
  /usr/share/cmake/Modules/FindBoost.cmake:892 (_Boost_COMPONENT_DEPENDENCIES)
  /usr/share/cmake/Modules/FindBoost.cmake:1523 (_Boost_MISSING_DEPENDENCIES)
  CMakeLists.txt:58 (find_package)

-- Boost version: 1.66.0

... and it worked. Thank you so much.