Skip to content

Help: Using Code App on iOS for cross-file C++ programming (I'm a beginner in C++ and not doing particularly complex development) #1305

Open

Description

@suiyutong61

Help: Using Code App on iOS for cross-file C++ programming (I'm a beginner in C++ and not doing particularly complex development)
Does the Code App on the iOS App Store support cross-file programming? For example, a folder containing myhead.h (function declarations), myfunction.cpp (function definitions), and main.cpp (a main function that calls the functions declared in myhead.h and defined in myfunction.cpp). If there is a way to achieve cross-file programming, please help me out. I don’t know how to properly compile and run files across multiple sources.
I tried entering commands in the terminal (the command was clang++ main.cpp my.cpp -o myPro), but the terminal kept reporting errors.!

Activity

  1. suiyutong61 commented on Jan 19, 2026

    @suiyutong61
    Author

    Does the Code App on the iOS App Store support cross-file programming? For example, a folder containing myhead.h (function declarations), myfunction.cpp (function definitions), and main.cpp (a main function that calls the functions declared in myhead.h and defined in myfunction.cpp). If there is a way to achieve cross-file programming, please help me out. I don’t know how to properly compile and run files across multiple sources.
    I tried entering commands in the terminal (the command was clang++ main.cpp my.cpp -o myPro), but the terminal kept reporting errors.

  2. Jakubpoland commented on Feb 14, 2026

    @Jakubpoland

    What I found that could help
    holzschu/a-shell#225 (comment)

  3. carinconc commented on Feb 18, 2026

    @carinconc

    You can use clang to compile the files manually; however, it is a must-have feature for C++ programmers to run a program with multiple .cpp files directly from the Code app. Hopefully, the developers will add this feature in a future version.

  4. Knoficooki commented on Feb 21, 2026

    @Knoficooki

    You can write a simple build script like this:

    mkdir -p build/obj
    clang++ <CLANG-OPTIONS> -c -o build/obj/<file1>.obj src/<file1>.cpp
    # ... do this for every source file
    
    clang++ <CLANG-OPTIONS> -o build/<bin> <files paths for bin in build/obj>

    The first clang calls only compile the sources into linkable object files (don't know if there is a difference using wasm) and the last call builds it into one "executable" (wasm) file

    Example:

    src/
     - main.cpp
     - helper.hpp
     - helper.cpp
    

    could be compiled using:

    mkdir -p build/obj
    # helper.cpp
    clang++ -Wall -Wextra -c -o build/obj/helper.obj src/helper.cpp
    # main.cpp
    clang++ -Wall -Wextra -c -o build/obj/main.obj src/main.cpp
    
    
    clang++ -o build/example build/obj/helper.obj /build/obj/main.obj

    use clang instead of clang++ for C

    but since running sh script (after trying) doesn't currently seem to be supported you can just put this in a python script, which executes each command (this can also simplify the process of adding new files to the build)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions