Add existing file to a Project

Sometimes you need to add already existing files to your project, for example AUTOSAR MCAL drivers. If you want to add existing source file to your project, you have these alternatives to do that:

Alternative 1

Import source files from the file system. The import procedure copies the source files into the project file system location.

Alternative 2

Create a link to an existing file in the file system. In this case, the original file is not copied and remains at their location. The project holds just a link to it.

Import source file

The import source file is the right option in case that you want to copy an existing source file into your workspace. In that case, you either select File  Import…​ or in the Project Explorer window right-click on project name  Import…​.

ide import source file
Fig. 1. Import source file

In the import wizard select General  File System and click to btnNext arrow.

ide import source file1
Fig. 2. Import source file - continue
  • Browse for the directory from where you want to import source files.

  • Select files to import.

  • Select destination folder within the project. MyProject/src in this case.

  • Click the btnFinish.

Once you finish the import wizard, all imported files appear in your project explorer view.

Linking existing file is beneficial in case you have to build source files, but you do not want to copy them into your workspace. In that case, you can create a link to them.

To create a link to file, please follow these steps:

  • Open import wizard by selecting the File  Import…​ or in the Project Explorer window right-click on project name  Import…​.

  • Browse for the directory from where you want to import source files.

  • Select files to import.

  • Select destination folder within the project. MyProject/whetstone in this case.

  • Click the btnAdvanced arrow

  • Set Create links in workspace option.

  • Set Create link location relative to: option.

  • Select path variable which best fit your needs. PROJECT_LOC is the default.

  • Click the btnFinish

ide link source file
Fig. 3. Link source file

Once you finish the import wizard, all linked files appear in your project explorer view.

You can easily distinguish the imported and linked sources according to their icons.

imported icon

Imported source file icon.

linked file icon

Linked source file icon

linked folder icon

Linked folder icon.