Zulip Chat Archive

Stream: lean4

Topic: Compile single file


James Sully (Mar 06 2024 at 03:42):

So Functional Programming in Lean mentions lean --run, then takes you through setting up and building a lake project. But is there a way to just compile a single file into a binary?

James Sully (Mar 06 2024 at 03:44):

lean hello.lean seems to do nothing, and I don't see any relevant flags under lean --help

Tomas Skrivan (Mar 06 2024 at 03:52):

This works

lean hello_world.lean -c hello_world.c && leanc hello_world.c -o hello_world && ./hello_world

for hello_world.lean file:

def main : IO Unit := do
  IO.println "Hello World"

leanc is just a wrapper around clang with the correct flags

James Sully (Mar 06 2024 at 03:53):

Thanks! I guess this is not the intended workflow lol

Tomas Skrivan (Mar 06 2024 at 03:54):

Yeah probably not but I used to do that before lake existed :)

James Sully (Mar 06 2024 at 03:55):

I'm sorry you had to go through that!

Mario Carneiro (Mar 06 2024 at 04:26):

lake exe hello_world is the normal way to do this with lake


Last updated: May 02 2025 at 03:31 UTC