Search code examples
buildcustomizationiar

Is there a way for IAR to build source code with the same name in different directory?


I am working on a project on IAR. The project will integrate a third party middleware source code directory. The directory have the following data sturcture

middleware
    |
    +--- tool1
    |      |
    |      +--- tool_imp.c
    |
    +--- tool2
    |      |
    |      +--- tool_imp.c        
    |
    +--- tool3
    |      |
    |      +--- tool_imp.c
    |
    +--- ...

In a word, the third party source code directory contains source code with the same name in different directory.

The code can be build OK with GCCARM. But when using IAR to build, the following error is encountered

Build error: Multiple tools write to the same file.

I checked the IAR project settings. The object files are specified to be generated in "$PROJ_DIR$/Debug/obj", so the same name .c file will generate the same name .o file in this directory and the latter will overwrite the former. I guess this is what the build error mean.

I don't want to change the file name in each directory. So is there any other way to fix this in IAR? Such as put object files in different directory, or concatenate dir name with source file name to form the object name?

Anyone solve this problem before?


Solution

  • That used to happen to me as well on earlier versions of the IAR IDE as all the tool_impl.o objects were being placed inside Debug\Obj so they were overwriting each other:

    Debug\Obj\
    Debug\Obj\tool_impl.o
    Debug\Obj\tool_impl.o <~ causes the build error
    Debug\Obj\tool_impl.o <~ causes the build error
    

    Currently (V9.30, for Arm), each logical "Group" will now render its own subdirectory inside Debug\Obj:

    Debug\Obj\
    Debug\Obj\middleware\
    Debug\Obj\middleware\tool1\tool_impl.o
    Debug\Obj\middleware\tool2\tool_impl.o 
    Debug\Obj\middleware\tool3\tool_impl.o
    

    So that they will not be overwritten by each other anymore.