You are here

Linking External C Files to a PSoC Designer Project with Imagecraft Compiler | Cypress Semiconductor

Support & Community

Linking External C Files to a PSoC Designer Project with Imagecraft Compiler

Last Updated: July 28, 2011

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, 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 file, an external c file has been linked.  To open file, click on Project -> "Open for this Project". Add the following lines to it.


# CSRCS is used by makedepends to get the external headers/dependencies 
CSRCS:=$(CSRCS) C:/ExtFile/ExtFunctions.c 
# 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. 
obj/%.o : C:/ExtFile/%.c 
ifeq ($(ECHO_COMMANDS),novice) 
      echo $(call correct_path,$<) 
      $(CCMD) $(CFLAGS) $(CDEFINES) $(INCLUDEFLAGS) $(DEFAULTCFLAGS) -o $@ $(call correct_path,$<)
There are some important points to note:
-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 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 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[0] blinks.
Attachments :
File TitleLanguageFile SizeLast Updated
Download Linking External C Files to a PSoC Designer Project with Imagecraft CompilerEnglish151.18 KB07/27/11
Knowledge Base Tags: 

Provide feedback on this article

Browse KB By Product

Browse KB by Type