By this stage my main.c became too big and I decided to split it into separate .h and .c’s. I manually corrected your_program.sh to include these files into compilation and it compiles ok on my machine when I ran this script, but the test runner fails to compile. Shouldn’t the test runner run your_program.sh?
your_program.sh:
#!/bin/sh
#
# Use this script to run your program LOCALLY.
#
# Note: Changing this script WILL NOT affect how CodeCrafters runs your program.
#
# Learn more: https://codecrafters.io/program-interface
set -e # Exit early if any commands fail
# Copied from .codecrafters/compile.sh
#
# - Edit this to change how your program compiles locally
# - Edit .codecrafters/compile.sh to change how your program compiles remotely
(
cd "$(dirname "$0")" # Ensure compile steps are run within the repository directory
# - add other .c files into compilation
gcc app/*.c app/**/*.c -o /tmp/shell-target
)
# Copied from .codecrafters/run.sh
#
# - Edit this to change how your program runs locally
# - Edit .codecrafters/run.sh to change how your program runs remotely
exec /tmp/shell-target "$@"
The runner gives following error:
[compile] /usr/lib/gcc/x86_64-alpine-linux-musl/8.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: /tmp/ccJoaCPj.o: in function `main':
[compile] main.c:(.text+0x20c5): undefined reference to `init_builtins'
[compile] /usr/lib/gcc/x86_64-alpine-linux-musl/8.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: main.c:(.text+0x2182): undefined reference to `parse_args'
[compile] /usr/lib/gcc/x86_64-alpine-linux-musl/8.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: main.c:(.text+0x218d): undefined reference to `builtIns'
[compile] /usr/lib/gcc/x86_64-alpine-linux-musl/8.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: main.c:(.text+0x21ac): undefined reference to `builtIns'
[compile] /usr/lib/gcc/x86_64-alpine-linux-musl/8.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: main.c:(.text+0x21b3): undefined reference to `builtIns'
[compile] /usr/lib/gcc/x86_64-alpine-linux-musl/8.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: main.c:(.text+0x21ba): undefined reference to `builtIns'
[compile] /usr/lib/gcc/x86_64-alpine-linux-musl/8.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: main.c:(.text+0x21e1): undefined reference to `getCommandLocation'
[compile] /usr/lib/gcc/x86_64-alpine-linux-musl/8.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: main.c:(.text+0x2347): undefined reference to `free_parse_result'
[compile] collect2: error: ld returned 1 exit status