Search code examples
cllvmcross-compilingdldc

Dlang LLVM ERROR: Program used external function which could not be resolved


main.d

import std.stdio;

void    main()
{
    writeln("Hello World !!!");
}

when i compile and execute it is work perfectly

But when i try

ldc2 -output-ll main.d
lli main.ll

LLVM ERROR: Program used external function '_d_throw_exception' which could not be resolved!

I try in c

#include<stdio.h>

void    main()
{
  printf("Hello World !!!");
}

and

clang -S -emit-llvm foo.c

lli foo.ll

it is work !!

Why in Dlang does not work when i compile width ldc ???


Solution

  • Because the cruntime is avilable to lli. Whereas the druntime is not. If you were to link the druntime and phobos into lli or load it at startup it would work.