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 project page cannot be used.
- During remote build, the project folder is copied to the remote environment, excluding the dump, model, and profiling directories in it.
- 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 project page, choose from the top menu bar to enter the build configuration page.
- 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 Configuration
Description
Name
Build configuration name.
Build Type
Configuration type. The options are Debug and Release.
Toolchain
Toolchain configurator, which supports local and remote 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.Environment from path
Enter a path or click
on the right to select the environment variable configuration file. The configuration file is filled in with one or more lines of <variable name>=<variable value>, for example:APATH=/usr/local/xxx X_PATH=/xxx/xxx
- 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 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 project page, choose from the top menu bar.
- 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.)
Environment variables
Enter the path of the dynamic load library (DLL).
You can also click
, and click
on the displayed page. Then, enter the path.Environment from path
Enter a path or click
on the right to select the environment variable configuration file. The configuration file is filled in with one or more lines of <variable name>=<variable value>, for example:APATH=/usr/local/xxx X_PATH=/xxx/xxx
- On the MindStudio project page, choose Run > Run... from the top menu bar.
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, check the detailed logs of the operating environment. For details, see the 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.
Running an Application Project (Remote)
- During remote running, the project folder is copied to the remote environment, excluding the dump and profiling directories in it.
- For a Python project, add an SSH Interpreter and select a remote environment interpreter in the run configuration to run the project remotely. For detailed configuration, see Python SDK Settings.
- Configure the remote toolchain.
- On the MindStudio project page, choose from the top menu bar to enter the build configuration page.
- In the Toolchain function area shown in Figure 4, choose Manage toolchains... on the right to access the toolchain configuration page.
- Configure the remote environment toolchain. For details, see Remote Build Configuration.
- In Build Configuration, select the configured remote toolchain and click OK to save it. Click the debug icon
on the toolbar to start debugging. For details, see Debugging.
- In the project directory on the left, right-click the project root directory, choose from the shortcut menu, and select and upload the project to the target remote environment.
- On the MindStudio project page, choose from the top menu bar.
- Click
in the upper left corner to create a CMake Application run configuration, select a remote executable file in the Executable function, and click OK. - On the MindStudio project page, choose Run > Run... from the top menu bar.
In the dialog box displayed, select the created run configuration and run the application.


