The following problems occur in the app source code obtained by referring to App Samples:
fatal error: acl/acl.h: No such file or directory
#include "acl/acl.h"
^~~~~~~~~~~
compilation terminated.
CMakeFiles/main.dir/build.make:62: recipe for target 'CMakeFiles/main.dir/main.cpp.o' failed
make[2]: *** [CMakeFiles/main.dir/main.cpp.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/main.dir/all' failed
make[1]: *** [CMakeFiles/main.dir/all] Error 2
Makefile:129: recipe for target 'all' failed/usr/bin/ld: cannot find -lascendcl collect2: error: ld returned 1 exit status CMakeFiles/main.dir/build.make:94: recipe for target '/home/HwHiAiUser/sample/resnet50_firstapp/out/main' failed make[2]: *** [/home/HwHiAiUser/sample/resnet50_firstapp/out/main] Error 1 CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/main.dir/all' failed make[1]: *** [CMakeFiles/main.dir/all] Error 2 Makefile:129: recipe for target 'all' failed
The {DDK_PATH} and {NPU_HOST_LIB} environment variables may be incorrectly set. In the samples provided in App Samples, these environment variables are used to search for AscendCL API header file and library file, which are the dependency files for the compilation of the app source code.
echo $DDK_PATH
Information similar to the following is displayed: (If no information is displayed, the environment variable is not set. Set it by referring to 4.)
/home/HwHiAiUser/Ascend/ascend-toolkit/latest
echo $NPU_HOST_LIB
Information similar to the following is displayed: (If no information is displayed, the environment variable is not set. Set it by referring to 4.)
/home/HwHiAiUser/Ascend/ascend-toolkit/latest/runtime/lib64/stub
The compilation script of the sample searches for the header file on which compilation depends based on the {DDK_PATH}/runtime/include/acl directory. Therefore, you can check whether this directory exists. If yes, check whether the acl.h header file exists in this directory. If either the directory or the header file does not exist, set {DDK_PATH} again by referring to 4.
cd /home/HwHiAiUser/Ascend/ascend-toolkit/latest/runtime/include/acl
ll acl.h
The compilation script of the sample searches for the library file on which compilation depends based on the directory specified by {NPU_HOST_LIB}. Therefore, you can check whether this directory exists. If yes, check whether the libascendcl.so library file exists in this directory. If either the directory or the library file does not exist, set {NPU_HOST_LIB} again by referring to 4.
cd /home/HwHiAiUser/Ascend/ascend-toolkit/latest/runtime/lib64/stub
ll libascendcl.so
The compilation script searches for the header file on which compilation depends based on the {DDK_PATH}/runtime/include/acl directory, and searches for the library file based on the directory specified by {NPU_HOST_LIB}. Replace $HOME/Ascend with the actual Ascend-CANN-Toolkit installation path.
export DDK_PATH=$HOME/Ascend/ascend-toolkit/latest export NPU_HOST_LIB=$DDK_PATH/runtime/lib64/stub
For example, if the development environment uses the x86 architecture and the operating environment uses the AArch64 architecture, cross compilation is involved. In this case, you need to install the software package of the AArch64 architecture in the development environment and set the {DDK_PATH} environment variable to the installation directory of this software package. In this way, the header file and library file in the software package are the same as those in the operating environment, which facilitates code compilation.
export DDK_PATH=$HOME/Ascend/ascend-toolkit/latest/arm64-linux export NPU_HOST_LIB=$DDK_PATH/runtime/lib64/stub
If multiple software versions are installed in the environment, select a version as required. By default, the latest directory points to the last installed software version.
If there are multiple acl.h and libascendcl.so files in the same version, some of them are soft links for compatibility with earlier versions. This helps users compile app source code in earlier versions.