Configuring C Projects
In order to map your C code, Atlas needs the same settings that the compiler needs to build your project. The following guide explains common ways to import an existing C code base into an Eclipse CDT project, and to prepare it for mapping with Atlas.
If the project requires a special compiler (other than gcc), you may need to install additional CDT features. In particular, if your project requires a gcc-based cross compiler, you may need to install the CDT feature "C/C++ GCC Cross Compiler Support".
Contents
Importing C projects in Eclipse
- If the project has a Makefile:
- From the File menu, select Import.
- In the popup dialogue, expand C/C++, select Existing Code as Makefile Project, and click Next.
- Enter a project name and indicate the directory to import. Set the Toolchain for Indexer Settings. For cross compilation with gcc, select Cross GCC.
- Click Finish.
- If the project does NOT have a Makefile:
- From the File menu, select New, then Other… .
- In the popup dialogue, expand C/C++, select C Project, and click Next.
- Expand the Project type Executable, and click Empty Project.
- Enter a project name and click Finish.
- Right-click on the project and select Import.
- In the popup dialogue, expand General, select File System, and click Next.
- Enter the parent directory, select files to import, and click Finish.
- Make adjustments to the include paths and preprocessor directives as needed. Right-click on the project, folders, or files, and select Properties.
- In the popup dialog, expand C/C++ Build and select Settings. Add include paths and preprocessor directives as needed. See also: CDT Help.
Configuring C projects for Atlas
At this point, your C project may be already configured correctly. In order for Atlas to obtain compiler settings (such as include paths and preprocessor directives), the CDT must be able to build your C project and observe invocations of your compiler. Review the steps below to ensure that Atlas can extract compiler information from the build process.
If your project uses a gcc-based cross compiler, configure the project to use it (instructions adapted from stackoverflow.com).
- Right-click on the project and select Preferences.
- Ensure the project is configured to use the Cross GCC Tool Chain.
- Expand C/C++ Build and select Tool Chain Editor.
- Set the Current toolchain to Cross GCC.
- Click Apply.
- In the popup dialog, select C/C++ Build.
- Check Generate Makefiles automatically, but do NOT Apply.
- Under C/C++ Build, select Settings.
- Under the Tool Settings tab, select Cross Settings. Set the cross compiler settings for Prefix and Path. For example:
- Prefix: arm-none-eabi-
- Path: /usr/bin
- Select C/C++ Build again, uncheck Generate Makefiles automatically.
- Click Apply.
The steps below detail the changes necessary to accurately map the files built by the Makefile.
- Ensure that the CDT can observe invocations of your compiler during a build. Makefiles for large projects (such as Linux) suppress the full text of the invocation for readability, but there is usually a way to emit the invocations in verbose mode.
- Select C/C++ Build and uncheck "Use default build command". Adjust the command to make the output verbose. Common options include “make V=1” or “make VERBOSE=1”.
- Configure Atlas to observe the build:
- Right-click on the project and select Properties.
- Select Atlas C Build.
- Under Build Commands, add the name of the compiler used by the project. Atlas will look for invocations of these compilers when parsing the output of the project's build.
- Under Source files to map, select Map only files in current build.
- Click OK.
Build
- To accurately map the project, it must be built so that the compiler invocations can be observed.
- If your project uses a CDT-generated Makefile, or the Makefile has an “all” target
- Right-click on the project in the Project Explorer and select Build Project
- If your project has a hand-written Makefile
- Right-click on the project in the Project Explorer and expand Build Targets and select Create… .
- In Target name, enter the name of the build target. Click OK.
- In the Project Explorer view, expand the project, expand the Build Targets, and double-click on the target.
Map
- After the project has been successfully built, it can be mapped with Atlas.
- Right-click on the project in the Project Explorer, expand Atlas, and select Enable Mapping.
- Select Atlas from the main menu, and select Re-Map Workspace.
Troubleshooting
If Atlas is unable to properly map the project, try the following:
- Clean and build the project and make sure the build output is being correctly parsed:
- Right-click on the project in the package explorer and select Properties.
- Look under Atlas C Build > Build Configuration File.
- If the Open button under Build Configuration File is grayed out, or if it says zero files were found, then Atlas was unable to detect the build configuration. Select C/C++ Build and uncheck “Use default build command”.
- Adjust the command to make the output verbose. Necessary flags may vary; common options include “V=1” or “VERBOSE=1”.
- Clean and build the project. Check that Build Configuration File is nonzero.
- If Atlas’ code map is still empty, it may be that the Makefile is improperly reporting changing directories.
- Right-click on the project in the package explorer and select Properties.
- Select C/C++ Build and uncheck “Use default build command”.
- Add the flag “--print-directory”.
- Clean and build the project.
For versions of Atlas before Atlas 3.0, see the instructions at Configuring C Projects for Atlas 2.0.
If you experience difficulty in setting up Atlas, please contact [email protected] for assistance.