Question: How to Link External C files to a PSoC Designer Project with Imagecraft compiler?
To link the external files located outside the project directory, to the PSoC Designer project, Local.mk file has to be edited. This is explained in "IDE User Guide" Documentation. ( Help -> Documentation -> Designer Specific Documents) in section B.5.3.
The Sample project has been attached here which has been compiled correctly in PD5.1 with Imagecraft compiler. By adding following lines to local.mk file, an external c file has been linked. To open local.mk file, click on Project -> "Open Local.mk for this Project". Add the following lines to it.
# CSRCS is used by makedepends to get the external headers/dependencies
# new rule to tell MAKE to get C files from C:/ExtFile
# DON'T have files in COMMON with the same name as this project's Source
# Files because we won't know which file MAKE will build last.
-There is a Tab(Not spaces) at the start of lines "echo ...." and " $(CCMD)...". This is important, if you copy and paste these lines to the local.mk file.
-You need to declare the functions which are defined in external C file at the top of your main code. Otherwise the compiler throws a warning.
-You do not need to add any "include" statements to your main code. Also, if you are using .h or include files located in an external directory, this process would have to be modified because the builder will not be able to find the files.
-These lines added to local.mk file will only work for Imagecraft compiler and not for Hi-Tech compiler.
In this example project, the external file "ExtFunctions.c" located in C:/Extfile has been linked. To test the project,
1. open the zip file attached and extract the contents.
2. Copy the 'ExtFile' folder to C: Drive.
3. Open the "Add_External_C_File" Project.
4. Generate and build the project.
5. Using CY3210 Kit, Download the code to CY8C29466-PXI device.
6. Verify whether the LED Connected to P0 blinks.