none
How to compile files in subdirectories? RRS feed

  • Question

  • I inherited a WINCE600 project with a large number of source files in a flat directory structure.
    I want to group the files in several subdirs according to function, but I can't get the relocated files to compile. (I am not refering to building libraries, not yet...)
    As a trivial example, lets say I have a project containing only two source files, File_1.cpp and File_2.cpp.

    This compiles and links succesfully

    In file SOURCES:
        ...
        SOURCES= \
            File_1.cpp \
            File_2.cpp \
        ...
        
    ------ Build started: Project: XXX, Configuration: VPGlass ARMV4I Release Platform Builder (_TGTCPU) ------
    C:\WINCE600\OSDesigns\XXX\subprojects\Project_A\sources
    Starting Build: set WINCEREL=1&&build -c
    ==============
    BUILD: [Thrd:Sequence:Type  ] Message
    ...
    BUILD: [00:0000000012:PROGC ] Building COMPILE Pass in C:\WINCE600\OSDesigns\XXX\subprojects\Project_A\ directory.
    BUILD: [01:0000000027:PROGC ] Compiling .\File_1.cpp
    BUILD: [01:0000000030:PROGC ] Compiling .\File_2.cpp
    BUILD: [00:0000000038:PROGC ] Building LINK Pass in C:\WINCE600\OSDesigns\XXX\subprojects\Project_A\ directory.
    BUILD: [01:0000000054:PROGC ] Linking obj\ARMV4I\retail\Project_A.exe
    ...
    ========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========


    But this fails:

    In file SOURCES:
        ...
        SOURCES= \
            File_1.cpp \
            Subdir\File_2.cpp \
        ...

    ------ Build started: Project: XXX, Configuration: VPGlass ARMV4I Release Platform Builder (_TGTCPU) ------
    C:\WINCE600\OSDesigns\XXX\subprojects\Project_A\sources
    Starting Build: set WINCEREL=1&&build -c
    ==============
    BUILD: [Thrd:Sequence:Type  ] Message
    ...
    BUILD: [00:0000000012:PROGC ] Building COMPILE Pass in C:\WINCE600\OSDesigns\XXX\subprojects\Project_A\ directory.
    BUILD: [01:0000000027:PROGC ] Compiling .\File_1.cpp
    BUILD: [01:0000000030:ERRORE] NMAKE :  U1073: don't know how to make 'obj\ARMV4I\retail\File_2.obj'
    BUILD: [01:0000000032:ERRORE] NMAKE.EXE TargetCompilePass  -i -c BUILDMSG=Stop.  BUILDROOT=C:\WINCE600\OSDesigns\XXX\subprojects\Project_A\ CLEANBUILD=1 NOLINK=1 NOPASS0=1 failed - rc = 2
    ...
    ========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========
       
    Tuesday, June 18, 2013 10:36 PM

All replies

  • Hi,

    Try using full path for e.g. if you're directory structure is maintained as this:

    DirA -- contains file 1

    DirB -- Contains file 2

    in sources file try ..\DirB\file2.cpp

    Regards,

    Balaji.

    Wednesday, June 19, 2013 3:37 AM
  • How about this ?

        SOURCES= \
            File_1.cpp \
             ..\Subdir\File_2.cpp \

    Regards,

    Rakesh.


    Wednesday, June 19, 2013 5:43 AM
  • Thanks for the replies, but no, that didn't work.

    (I tried also more variations, starting from $(_PROJECTROOT) or C:\WINCE600\ ... etc.)

    Wednesday, June 19, 2013 3:51 PM
  • Hi

    You can try putting the sources file in the subdir and calling the File_1.cpp from there.

    In SOURCES:
        ...
        SOURCES= \
            ..\File_1.cpp \
            File_2.cpp \

    Hope this helps..

    Monday, June 24, 2013 6:31 AM
  • That should work, but wouldn't it be better to move all of the files to subfolders, then use DIRS and sources to build libs and finally link the libs?

    Bruce Eitman (eMVP)
    Senior Engineer
    Bruce.Eitman AT Eurotech DOT com
    My BLOG http://geekswithblogs.net/bruceeitman

    Eurotech Inc.
    www.Eurotech.com

    Monday, June 24, 2013 12:55 PM
    Moderator
  • @ r_waltman

    The SOURCES file instruct the compiler to associate the files for the project in the current folder.

    After you moved the project from a flat structure to sub-folder structure, did you add DIRS file to instruct the compiler to compile the sub-folder?

    Without a proper DIRS file, the codes that you moved to the sub-folder will not compile.

    If you are not familiar with DIRS, take a look at the one that came with the project, while it was organized in a flat directory structure.  The entry in the DIRS file tells the compiler which directory to compile. 


    Samuel Phung [eMVP] Blog: http://www.embedded101.com/samuelp101/ Twitter: @Samuelp101

    Wednesday, June 26, 2013 4:53 PM
  • Thanks for the replies, but no, that didn't work.

    (I tried also more variations, starting from $(_PROJECTROOT) or C:\WINCE600\ ... etc.)

    I answered a similar question at:

    http://stackoverflow.com/questions/17692529/windows-compact-embedded-include-external-native-files

    Friday, April 4, 2014 10:20 AM