ldc2 Verified current stable Not installed? Programming

Ldc2 / Compile Source Without Linking

Compile Source Without Linking

Compile D source files into object files without linking.

$
Terminal
ldc2 -c <path/to/source.d>

When To Use

When building modular code and dependencies are resolved separately for linking later.

Pro Tip

Ensure the object files generated are placed in a known directory for efficient linking later.

Command Builder

Tune the command before you copy it

Back to syntax
$
Generated Command
ldc2 -c <path/to/source.d>

Anatomy of Output

Understanding the result

Compiling /path/to/source.d without linking... Compilation Start

Indicates the start of compilation for an object file.

Created object file: /path/to/source.o Output Confirmation

Confirms object file was generated successfully.

Total time: 32 seconds Compile Duration

Time taken to complete compilation.

Power User Variants

Optimized versions

ldc2 -c path/to/source.d -g

Generate debug symbols while compiling.

ldc2 -c path/to/source.d -Ofast

Compile with optimizations but without linking.

Unix Pipeline

Shell combinations

ldc2 -c path/to/source.d -o object_file.o

Specify output object file name directly.

Troubleshooting

Common pitfalls

Error: cannot find source file.

Solution: Verify the file path is accurate.

Error: Unsupported source file type.

Solution: Ensure the source file has a valid .d extension.

Error: Internal compiler error.

Solution: Check compiler version or run with verbose logging for additional details.

Command Breakdown

What each part is doing

ldc2
Base Command
The executable that performs this operation. Here it runs Ldc2 before the shell applies any redirect operators.
<path/to/source.d>
path to source.d
The value supplied for path to source.d.
-c
Command Option
Tool-specific option used by this command invocation.

Alternative Approaches

Comparable commands in other tools

Alternative programming tools for the same job.