In the Linux Scenario
Building an Application Project
- If the new application project is of the Python version, you do not need to build the project. In this case, the Build function on the MindStudio IDE project page cannot be used.
- Before build, confirm the environment variables in the set_env.cmake file under the project directory and replace the installation path of the CANN package.
- (Optional) Modify the src/CMakeLists.txt file in the project directory.
- include_directories: Add the directories of the header files to be included.
The following is an example:
include_directories( directoryPath1 directoryPath2 )
- link_directories: Add the directories of the library files to be linked with.
The following is an example:
link_directories( directoryPath3 directoryPath4 )
- add_executable: Add the directory of the .cpp file.
The following is an example:
add_executable( main directoryPath5 directoryPath6 )
- target_link_libraries: Add the library files on which application building depends.
The following is an example:
target_link_libraries( main ascendcl libName1 libName2)
- install: Install the build output main to a specified path.
The following is an example:
install(TARGETS main DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
- include_directories: Add the directories of the header files to be included.
- (Optional) Specify CMakeLists.txt as the configuration file for project build.
Find the CMakeLists.txt file in the directory on the left of the project page, right-click the file, and choose Load CMake Project from the shortcut menu to specify it as the configuration file for project build, as shown in Figure 1.
- Perform build configuration.On the MindStudio IDE project page, click
in the upper left corner. On the top menu bar, click . The compilation configuration page is displayed.
- Set build parameters and click
to add configurations.
The configuration option marked with (default) in the list is the default one. To switch the default option to a custom option, select the custom option and click
.Figure 2 Build configuration
Table 1 Description of build configuration parameters Parameter
Description
Name
Build configuration name.
Build Type
Configuration type. The options are Debug and Release.
Toolchain
Toolchain configurator, which supports local build. For details about the configuration, see Toolchains.
CMake options
CMake option. The default value is -DCMAKE_BUILD_TYPE=Debug -DCMAKE_SKIP_RPATH=TRUE.
Build directory
Relative path of the build directory, which is relative to the project directory.
Build options
Build acceleration option.
Environment Variables
Environment variable configuration.
You can manually configure the environment variables or click
to configure them in the dialog box displayed. - Click OK to save the build project.
- Set build parameters and click
- Select one of the following build methods based on the application scenario on the MindStudio IDE project page.
- Choose and clear build configurations. (The Clean CMake Project function supports only local build.)
- Choose to use the default configurations for full build.
- Choose or click
on the toolbar to use the default configurations for incremental build.
If the message "Build finished" is displayed, the build is complete.
Running an Application Project (Local)
- On the MindStudio IDE project page, click
in the upper left corner. On the top menu bar, click . The compilation configuration page is displayed. - Click + in the upper left corner, choose CMake Application, and configure the run parameters of the application project. Figure 3 shows a configuration example. After the configuration is complete, click Apply to save the run configuration and click OK to close the run configuration dialog box.
Table 2 Run configuration options Configuration Option
Description
Executable
Select the path of the build executable file to the last level.
Program arguments
Run parameters.
Working directory
Working directory. (If relative paths are configured in the project, select a relative working directory here, which defaults to the directory where the executable file is located.)
Enviroment variables
Enter the path of the dynamic load library (DLL).
You can also click
, and click
on the displayed page. Then, enter the path. - On the MindStudio IDE project page, click
in the upper left corner. On the top menu bar that is displayed, click Run > Run....In the dialog box displayed, select the created run configuration and run the application.
- If no error message is displayed and the message "Running *** finished" is displayed, the execution is complete.
- If an error message is displayed during application execution, view the detailed logs of the operating environment. For details, see Log Reference.
- The default log path is $HOME/ascend/log. For details, see the "Log Files" section.
- The default log level is ERROR. For details about how to query or change the log level, see the "Log Level Setting" section.

