[LLVMdev] generating executable file from .ll files

Duncan Sands baldrick at free.fr
Sat Jan 12 13:01:32 PST 2013


Hi Ali,

 > I'm writing a front-end for llvm with java. my front-end produces .ll files.
> Then I use the following commands to convert these files to an executable file:
> !. for each .ll file I use 'llvm-as file.ll' to create  a bitcode file
> 2. use 'llvm-ld -o executable my-bitcode-files -L/usr/lib/i386-linux-gnu
> -lstdc++' to generate  an executable file

add -native otherwise it doesn't create a real executable, only a wrapper
script around the linked bitcode.

> then when I run the executable file, I get the following error:
>
> LLVM ERROR: Program used external function '_Znwm' which could not be resolved!
>
> what should I do to resolve this issue?

An alternative is to use llc to compile each .ll into a .s file, then do:
   gcc -o executable all-the-.s-files -L/usr/lib/i386-linux-gnu -lstdc++

You could instead use an LLVM aware linker (eg the gold plugin) if you want link
time optimization.

Ciao, Duncan.



More information about the llvm-dev mailing list