Skip to content

Building a Stack Project

To build a stack project, we change into the project's directory

Shell
$ cd hello-world

and then we run

GHCi
$ stack build
hello-world-0.1.0.0: unregistering (local file changes: CHANGELOG.md README.md app/Main.hs hello-world.cabal package.yaml src/Lib.hs)
Building all executables for `hello-world' once. After a successful build of all of them, only specified executables will be rebuilt.
hello-world> configure (lib + exe)
Configuring hello-world-0.1.0.0...
hello-world> build (lib + exe)
Preprocessing library for hello-world-0.1.0.0..
Building library for hello-world-0.1.0.0..
[1 of 2] Compiling Lib
[2 of 2] Compiling Paths_hello_world
ld: warning: directory not found for option '-L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib'
ld: warning: -undefined dynamic_lookup may not work with chained fixups
Preprocessing executable 'hello-world-exe' for hello-world-0.1.0.0..
Building executable 'hello-world-exe' for hello-world-0.1.0.0..
[1 of 2] Compiling Main
[2 of 2] Compiling Paths_hello_world
Linking .stack-work/dist/aarch64-osx/Cabal-3.6.3.0/build/hello-world-exe/hello-world-exe ...
ld: warning: directory not found for option '-L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib'
hello-world> copy/register
Installing library in /Users/nzeh/Documents/Teaching/Courses/3137/hello-world/.stack-work/install/aarch64-osx/30665e6a8eb3dd4cf3caecaaed8af8f238959b36768fc4cd801124b81c392c48/9.2.7/lib/aarch64-osx-ghc-9.2.7/hello-world-0.1.0.0-1KSZdJDf3OpDn2vAhzFXYs
Installing executable hello-world-exe in /Users/nzeh/Documents/Teaching/Courses/3137/hello-world/.stack-work/install/aarch64-osx/30665e6a8eb3dd4cf3caecaaed8af8f238959b36768fc4cd801124b81c392c48/9.2.7/bin
Registering library for hello-world-0.1.0.0..

You can ignore most of the output. What we care about is that the compiler didn't produce any error messages in this example.