I am seeing a pthread error while running cmake to configure the build

Has anyone else seen this ?

```
Performing C SOURCE FILE Test CMAKE_HAVE_LIBC_PTHREAD failed with the
following output:
Change Dir: /home/nyue/projects/OpenImageIO/
2.3.19.0/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/ninja cmTC_0810d && [1/2] Building C object
CMakeFiles/cmTC_0810d.dir/src.c.o
[2/2] Linking C executable cmTC_0810d
FAILED: cmTC_0810d
: && /usr/bin/cc   CMakeFiles/cmTC_0810d.dir/src.c.o -o cmTC_0810d   && :
/usr/bin/ld: CMakeFiles/cmTC_0810d.dir/src.c.o: in function `main':
src.c:(.text+0x46): undefined reference to `pthread_create'
/usr/bin/ld: src.c:(.text+0x52): undefined reference to `pthread_detach'
/usr/bin/ld: src.c:(.text+0x5e): undefined reference to `pthread_cancel'
/usr/bin/ld: src.c:(.text+0x6f): undefined reference to `pthread_join'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.


Source file was:
#include <pthread.h>

static void* test_func(void* data)
{
  return data;
}

int main(void)
{
  pthread_t thread;
  pthread_create(&thread, NULL, test_func, NULL);
  pthread_detach(thread);
  pthread_cancel(thread);
  pthread_join(thread, NULL);
  pthread_atfork(NULL, NULL, NULL);
  pthread_exit(NULL);

  return 0;
}

Determining if the function pthread_create exists in the pthreads failed
with the following output:
Change Dir: /home/nyue/projects/OpenImageIO/
2.3.19.0/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/ninja cmTC_589eb && [1/2] Building C object
CMakeFiles/cmTC_589eb.dir/CheckFunctionExists.c.o
[2/2] Linking C executable cmTC_589eb
FAILED: cmTC_589eb
: && /usr/bin/cc -DCHECK_FUNCTION_EXISTS=pthread_create
 CMakeFiles/cmTC_589eb.dir/CheckFunctionExists.c.o -o cmTC_589eb
 -lpthreads && :
/usr/bin/ld: cannot find -lpthreads
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
```

My cmake command is as follow

```
#!/bin/sh
rm -f CMakeCache.txt
cmake -Wno-dev \
 -D BUILD_MISSING_DEPS=ON \
 -D CLANG_FORMAT_EXE=$HOME/systems/llvm/14.0.6/bin/clang-format \
 -D BUILD_TESTING=OFF \
 -D USE_PYTHON=OFF \
 -D USE_QT=ON \
 -D BUILD_SHARED_LIBS=OFF \
 -D Boost_ROOT=$HOME/systems/boost/1.80.0 \
 -D OpenEXR_ROOT=$HOME/systems/openexr/3.1.5 \
 -D Imath_DIR=$HOME/systems/imath/3.1.5/lib/cmake/Imath \
 -D CMAKE_BUILD_TYPE=Release \
 -D CMAKE_INSTALL_PREFIX=$HOME/systems/oiio/2.3.19.0 \
 -G "Ninja" \
 ../oiio-2.3.19.0
```

Cheers
-- 
Nicholas Yue
https://www.linkedin.com/in/nicholasyue/
_______________________________________________
Oiio-dev mailing list
Oiio-dev@lists.openimageio.org
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org

Reply via email to