Crystal: Unable to compile Hello World on Mac OSX Sierra

Created on 13 Sep 2017  Â·  7Comments  Â·  Source: crystal-lang/crystal

Crystal 0.23.1 (2017-09-08) LLVM 4.0.1

{21:29}~/Learning/crystal âž­ crystal -v Crystal 0.23.1 (2017-09-08) LLVM 4.0.1 {21:29}~/Learning/crystal âž­ less hello.cr puts "Hello World"

compiling it produces this error

{21:28}~/Learning/crystal âž­ crystal hello.cr ld: library not found for -levent clang: error: linker command failed with exit code 1 (use -v to see invocation) Error: execution of command failed with code: 1: 'cc "${@}" -o '/Users/dayas/.cache/crystal/crystal-run-hello.tmp' -rdynamic -lpcre -lgc -lpthread /usr/local/Cellar/crystal-lang/0.23.1_1/src/ext/libcrystal.a -levent -liconv -ldl -L/usr/lib -L/usr/local/lib'

I have tried the XCode steps

{21:23}~/Learning/crystal âž­ sudo xcode-select --install Password: Sorry, try again. Password: xcode-select: error: command line tools are already installed, use "Software Update" to install updates {21:23}~/Learning/crystal âž­ sudo xcode-select --switch /Library/Developer/CommandLineTools

exact details are here https://gist.github.com/a193c36cbe66fa49b3899354b934fd99

what am I doing wrong?

question

Most helpful comment

@asterite Thanks for that pointer, I did have libevent installed but wasn't properly linked doing brew link --overwrite libevent fixed it

Thanks everyone for the help.

All 7 comments

The installation docs describe a situation here which might be related to your problem.

Are you referring to the Xcode steps? I already tried those but that doesn't help :(

@daya could you try otool -L $(which crystal) and brew info crystal-lang libevent?

@matiasgarciaisaia seems like some of the dependencies are missing

{9:30}~/Learning/crystal âž­ otool -L $(which crystal)
/usr/local/bin/crystal:
    /usr/lib/libncurses.5.4.dylib (compatibility version 5.4.0, current version 5.4.0)
    /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.8)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.50.2)
    /usr/local/opt/llvm@4/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1.0.0)
    /usr/local/opt/pcre/lib/libpcre.1.dylib (compatibility version 4.0.0, current version 4.9.0)
    /usr/local/opt/bdw-gc/lib/libgc.1.dylib (compatibility version 2.0.0, current version 2.3.0)
    /usr/local/opt/libevent/lib/libevent-2.1.6.dylib (compatibility version 7.0.0, current version 7.2.0)
    /usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
    /usr/lib/libc++abi.dylib (compatibility version 1.0.0, current version 307.3.0)

here is the brew output that shows libatomic_ops ✘, automake ✘, doxygen ✘, libtool ✘ as missing. I am pretty sure automake missing is bad

https://gist.github.com/cbce788a2d4ce01165700bf10c53062b

{10:08}~/Learning/crystal âž­ brew info crystal-lang libevent
crystal-lang: stable 0.23.1 (bottled), HEAD
Fast and statically typed, compiled language with Ruby-like syntax
https://crystal-lang.org/
/usr/local/Cellar/crystal-lang/current (812 files, 45.7MB)
  Poured from bottle on 2017-09-12 at 20:17:57
/usr/local/Cellar/crystal-lang/0.23.1_1 (812 files, 45.7MB) *
  Poured from bottle on 2017-09-12 at 20:17:57
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/crystal-lang.rb
==> Dependencies
Build: pkg-config ✔, libatomic_ops ✘
Required: libevent ✔, bdw-gc ✔, llvm@4 ✔, pcre ✔, gmp ✔, libyaml ✔
==> Options
--without-release
    Do not build the compiler in release mode
--without-shards
    Do not include `shards` dependency manager
--HEAD
    Install HEAD version
==> Caveats
Bash completion has been installed to:
  /usr/local/etc/bash_completion.d

zsh completions have been installed to:
  /usr/local/share/zsh/site-functions

libevent: stable 2.1.8 (bottled)
Asynchronous event library
http://libevent.org
Conflicts with:
  pincaster (because both install `event_rpcgen.py` binaries)
/usr/local/Cellar/libevent/1.4.14b (20 files, 794.8KB)
  Built from source
/usr/local/Cellar/libevent/2.0.17 (53 files, 1.8MB)
  Built from source
/usr/local/Cellar/libevent/2.1.8 (847 files, 2.2MB)
  Poured from bottle on 2017-09-12 at 20:15:17
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/libevent.rb
==> Dependencies
Build: autoconf ✔, automake ✘, doxygen ✘, libtool ✘, pkg-config ✔
Required: openssl ✔
{10:08}~/Learning/crystal âž­

Any pointers will be much appreciated.

From the first output it seems you are missing libevent. You can try brew install libevent. I don't know why would that happen, though...

@asterite Thanks for that pointer, I did have libevent installed but wasn't properly linked doing brew link --overwrite libevent fixed it

Thanks everyone for the help.

If anyone has the time, this is a great candidate to a self-replied StackOverflow question!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

xtagon picture xtagon  Â·  132Comments

asterite picture asterite  Â·  78Comments

stugol picture stugol  Â·  70Comments

asterite picture asterite  Â·  139Comments

asterite picture asterite  Â·  71Comments