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!
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")