Crystal: Cannot compile on Manjaro Linux

Created on 10 Jul 2019  Â·  9Comments  Â·  Source: crystal-lang/crystal

Can't compile colorls-cr

Kernel: x86_64 Linux 4.19.56-1-MANJARO
crystal 0.29.0
LLVM 8.0.0

crystal build src/colorls.cr --no-debug --release
/usr/bin/ld: cannot find -ltermbox (this usually means you need to install the development package for libtermbox)
collect2: error: ld execution completed with return code 1
Error: execution of command failed with code: 1: `cc "${@}" -o '/home/andrew/crystal/colorls-cr/colorls' -lffi -rdynamic  -lyaml -L/usr/local/lib -ltermbox -lpcre -lm -lgc -lpthread /usr/lib/crystal/ext/libcrystal.a -levent -lrt -ldl -L/usr/lib -L/usr/local/lib`

How to cope with it?

All 9 comments

this usually means you need to install the development package for libtermbox

A quick google found: https://aur.archlinux.org/packages/termbox-git/

-- Ryan
https://refi64.com/
On Jul 9, 2019, 7:30 PM -0500, Andrew notifications@github.com, wrote:

Can't compile colorls-cr
Manjaro Linux Kernel: x86_64 Linux 4.19.56-1-MANJARO
crystal 0.29.0
LLVM 8.0.0
crystal build src/colorls.cr --no-debug --release
/usr/bin/ld: cannot find -ltermbox (this usually means you need to install the development package for libtermbox)
collect2: error: ld execution completed with return code 1
Error: execution of command failed with code: 1: cc "${@}" -o '/home/andrew/crystal/colorls-cr/colorls' -lffi -rdynamic -lyaml -L/usr/local/lib -ltermbox -lpcre -lm -lgc -lpthread /usr/lib/crystal/ext/libcrystal.a -levent -lrt -ldl -L/usr/lib -L/usr/local/lib
How to cope with it?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.

The compiler is not to blame when you can't use some outside library. I would recommend closing this issue.

The external dependency comes though here.
https://github.com/andrewsuzuki/termbox-crystal/blob/master/src/termbox/bindings.cr

Although the dependency is transitive, the author of colorls-cr should mention it.

I think it would be good to have a clearer error message, maybe with colors to highlight what the user can do to resolve the problem. (or even handle this kind of error completely and give something similar to the amazing compiler error output revamp)

I think we could even do better. If we can get figure out what OS and distribution crystal is running on we could suggest installing the package with apt-get, brew, etc. The hint will be something general, like, in Mac it'll be "The library for xxx is missing, maybe you can install with brew install xxx or something similar". That way the user can immediately know it's about a missing library of that kind (and not, say, a shard).

Of course there are many OS distributions, but we can take into account some popular ones and add more over time.

This is more in the realm of shards I think. Becuase in the shard.yml file you are able to declare the libraries needed. A command to show the required libraries of the nested dependencies would be needed.

That could help to show a generic command in the compiler when a library is missing.

But to get the actual instruction can be quite hard since there is no standard. It varies across distros, so it would be a best effort.

@bcardiff What about libxml2, which is in the standard library? Or libyaml?

No sure. Maybe shards could look for a shard.yml in all of the crystal path components.

I'm the author of colorls-cr. I've got an issue open on my repo where I'm looking into updating the README for this & referencing the termbox-crystal script for installing the library.

I think this is safe to close this issue, it's really a problem with my code/shard, not crystal itself.

Closing, the question has been answered. We can improve the error message, but that's another topic :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

asterite picture asterite  Â·  3Comments

Papierkorb picture Papierkorb  Â·  3Comments

cjgajard picture cjgajard  Â·  3Comments

oprypin picture oprypin  Â·  3Comments

asterite picture asterite  Â·  3Comments