AARCH64 tensorflow lite build problem

I’ve an ARM64 that I need to build tensorflow lite, and I’m using cmake. The cmake command fails when the pthread test code doesn’t build. The test code is:

#include <pthread.h>

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

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

return 0;
}

I build the test code manually with the following command, and it builds and runs.

cc src.c -lpthread

What is the cmake looking for that would cause this build to fail? I have LD_LIBRARY_PATH set to where the pthread library/so is. The cmake error output file is as follows. Why doesn’t the link command have -lpthread? Thank you.

Performing C SOURCE FILE Test CMAKE_HAVE_LIBC_PTHREAD failed with the following output:
Change Dir: /home/xilinx/tflite_build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/make cmTC_84682/fast && /usr/bin/make -f CMakeFiles/cmTC_84682.dir/build.make CMakeFiles/cmTC_84682.dir/build
make[1]: Entering directory ‘/home/xilinx/tflite_build/CMakeFiles/CMakeTmp’
Building C object CMakeFiles/cmTC_84682.dir/src.c.o
/usr/bin/cc -DCMAKE_HAVE_LIBC_PTHREAD -fPIE -o CMakeFiles/cmTC_84682.dir/src.c.o -c /home/xilinx/tflite_build/CMakeFiles/CMakeTmp/src.c
Linking C executable cmTC_84682
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_84682.dir/link.txt --verbose=1
/usr/bin/cc -DCMAKE_HAVE_LIBC_PTHREAD CMakeFiles/cmTC_84682.dir/src.c.o -o cmTC_84682
/usr/bin/ld: CMakeFiles/cmTC_84682.dir/src.c.o: in function main': src.c:(.text+0x48): undefined reference to pthread_create’
/usr/bin/ld: src.c:(.text+0x50): undefined reference to pthread_detach' /usr/bin/ld: src.c:(.text+0x5c): undefined reference to pthread_join’
collect2: error: ld returned 1 exit status
make[1]: *** [CMakeFiles/cmTC_84682.dir/build.make:87: cmTC_84682] Error 1
make[1]: Leaving directory ‘/home/xilinx/tflite_build/CMakeFiles/CMakeTmp’
make: *** [Makefile:121: cmTC_84682/fast] Error 2

Source file was:
#include <pthread.h>

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

int main(void)
{
pthread_t thread;
pthread_create(&thread, NULL, test_func, NULL);
pthread_detach(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/xilinx/tflite_build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/make cmTC_a7f5d/fast && /usr/bin/make -f CMakeFiles/cmTC_a7f5d.dir/build.make CMakeFiles/cmTC_a7f5d.dir/build
make[1]: Entering directory ‘/home/xilinx/tflite_build/CMakeFiles/CMakeTmp’
Building C object CMakeFiles/cmTC_a7f5d.dir/CheckFunctionExists.c.o
/usr/bin/cc -DCHECK_FUNCTION_EXISTS=pthread_create -fPIE -o CMakeFiles/cmTC_a7f5d.dir/CheckFunctionExists.c.o -c /usr/share/cmake-3.16/Modules/CheckFunctionExists.c
Linking C executable cmTC_a7f5d
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_a7f5d.dir/link.txt --verbose=1
/usr/bin/cc -DCHECK_FUNCTION_EXISTS=pthread_create CMakeFiles/cmTC_a7f5d.dir/CheckFunctionExists.c.o -o cmTC_a7f5d -lpthreads
/usr/bin/ld: cannot find -lpthreads
collect2: error: ld returned 1 exit status
make[1]: *** [CMakeFiles/cmTC_a7f5d.dir/build.make:87: cmTC_a7f5d] Error 1
make[1]: Leaving directory ‘/home/xilinx/tflite_build/CMakeFiles/CMakeTmp’
make: *** [Makefile:121: cmTC_a7f5d/fast] Error 2