Forums - fatal error: 'pthread.h' file not found

2 posts / 0 new
Last post
fatal error: 'pthread.h' file not found
yuanyaoshen
Join Date: 13 Jul 21
Posts: 5
Posted: Thu, 2021-08-05 16:20

Hi, when I compile the example: Hexagon_SDK/4.3.0.0/tools/HALIDE_Tools/2.3.03/Halide/Examples/offload/apps/hexagon_benchmarks/dilate3x3_generate.cpp using command:

$HL_HEXAGON_TOOLS/bin/hexagon-clang++ -std=c++11 -I $HALIDE_ROOT/include -stdlib=libc++ -O3 -g -fno-rtti -rdynamic dilate3x3_generator.cpp $HALIDE_ROOT/lib/libHalide.a $HALIDE_ROOT/tools/GenGen.cpp -o dilate3x3.generator -lz -lrt -ldl -lpthread -lm

I got error:

/opt/qcom/Hexagon_SDK/4.3.0.0/tools/HEXAGON_Tools/8.4.11/Tools/bin/../target/hexagon/include/c++/v1/__threading_support:27:11: fatal error: 'pthread.h' file not found
# include <pthread.h>
          ^~~~~~~~~~~

I looked for pthread.h under SDK root and I got:

./tools/android-ndk-r19c/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/pthread.h
./tools/android-ndk-r19c/sysroot/usr/include/pthread.h
./rtos/qurt/computev68/include/posix/pthread.h
./rtos/qurt/computev65/include/posix/pthread.h
./rtos/qurt/computev66/include/posix/pthread.h

I tried adding path but then I got a bunch of other 'not found' issues. Below is my setting for SDK:

export SDK_ROOT="/opt/qcom"
export HEXAGON_SDK_ROOT="$SDK_ROOT/Hexagon_SDK/4.3.0.0"
export HL_HEXAGON_TOOLS="$HEXAGON_SDK_ROOT/tools/HEXAGON_Tools/8.4.11/Tools"
export HALIDE_ROOT="$HEXAGON_SDK_ROOT/tools/HALIDE_Tools/2.3.03/Halide"
export ANDROID_NDK_HOME="$HEXAGON_SDK_ROOT/tools/android-ndk-r19c"
export ANDROID_ARM64_TOOLCHAIN="$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64"

I don't know what is the issue here. I noted another similar issue in 2018: https://developer.qualcomm.com/forum/qdn-forums/software/hexagon-dsp-sdk... but it is not answered. Any help is much appreciated!

  • Up0
  • Down0
maitreyi
Join Date: 21 Nov 18
Posts: 3
Posted: Sun, 2021-08-08 21:53

The header file `pthread.h` is included with the QuRT libraries. This issue is seen when a C++ based library is built as a standalone library (without linking to QuRT). Refer to the Makefiles of calculator_c++ example for building the library with `pthread.h` from QuRT.

Alternatively, if you do not want to link with QuRT, you can pass a compiler flag specifying a C++ standard, that has no build dependency on `pthread.h` such as C++03.

The compiler flag can be passed to the `hexagon.min` file as follows:

        CXX_FLAGS += -std=c++03

For CMake, the compiler flag can be passed to the `CMakeLists.txt` file as follows:

        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++03")

 

  • Up0
  • Down0
or Register

Opinions expressed in the content posted here are the personal opinions of the original authors, and do not necessarily reflect those of Qualcomm Incorporated or its subsidiaries (“Qualcomm”). The content is provided for informational purposes only and is not meant to be an endorsement or representation by Qualcomm or any other party. This site may also provide links or references to non-Qualcomm sites and resources. Qualcomm makes no representations, warranties, or other commitments whatsoever about any non-Qualcomm sites or third-party resources that may be referenced, accessible from, or linked to this site.