PMunch/futhark

Cannot find clang

Patitotective opened this issue · 6 comments

I'm trying to install futhark and I already have clang installed, but it fails saying /usr/bin/ld: cannot find -lclang

$ clang -v
Ubuntu clang version 13.0.0-2
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/10
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/11
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/11
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64
$ nimble install futhark --verbose
    Reading official package list
Downloading https://github.com/PMunch/futhark using git
    Cloning latest tagged version: v0.5.1
   Warning: Package 'futhark' has an incorrect structure. The top level of the package source directory should contain at most one module, named 'futhark.nim', but a file named 'opir.nim' was found. This will be an error in the future.
      Hint: If this is the primary source file in the package, rename it to 'futhark.nim'. If it's a source file required by the main module, or if it is one of several modules exposed by 'futhark', then move it into a 'futhark/' subdirectory. If it's a test file or otherwise not required to build the the package 'futhark.nim', prevent its installation by adding `skipFiles = @["opir.nim"]` to the .nimble file. See https://github.com/nim-lang/nimble#libraries for more info.
  Verifying dependencies for futhark@0.5.1
    Reading official package list
   Checking for https://github.com/PMunch/libclang-nim@#head
      Info: Dependency on https://github.com/PMunch/libclang-nim@#head already satisfied
  Verifying dependencies for clang@#head
    Reading official package list
   Checking for termstyle@any version
      Info: Dependency on termstyle@any version already satisfied
  Verifying dependencies for termstyle@0.1.0
    Reading official package list
   Checking for macroutils@any version
      Info: Dependency on macroutils@any version already satisfied
  Verifying dependencies for macroutils@1.2.0
 Installing futhark@0.5.1
   Building futhark/opir using c backend
  Executing /home/cristobal/nim/nim-1.6.5/bin/nim c --colors:on --noNimblePath -d:release -d:NimblePkgVersion=0.5.1 --path:'/home/cristobal/.nimble/pkgs/clang-#head' --path:/home/cristobal/.nimble/pkgs/termstyle-0.1.0 --path:/home/cristobal/.nimble/pkgs/macroutils-1.2.0 -o:/tmp/nimble_23317/githubcom_PMunchfuthark/opir /tmp/nimble_23317/githubcom_PMunchfuthark/src/opir.nim
Hint: used config file '/home/cristobal/nim/nim-1.6.5/config/nim.cfg' [Conf]
Hint: used config file '/home/cristobal/nim/nim-1.6.5/config/config.nims' [Conf]
Hint: used config file '/tmp/nimble_23317/githubcom_PMunchfuthark/src/opir.nims' [Conf]
.........................................................................................................
/tmp/nimble_23317/githubcom_PMunchfuthark/src/opir.nim(20, 6) Hint: 'getRange' is declared but not used [XDeclaredButNotUsed]
CC: stdlib_digitsutils.nim
CC: stdlib_assertions.nim
CC: stdlib_formatfloat.nim
CC: stdlib_dollars.nim
CC: stdlib_io.nim
CC: stdlib_system.nim
CC: stdlib_parseutils.nim
CC: stdlib_math.nim
CC: stdlib_algorithm.nim
CC: stdlib_strutils.nim
CC: stdlib_pathnorm.nim
CC: stdlib_times.nim
CC: stdlib_os.nim
CC: stdlib_hashes.nim
CC: stdlib_tables.nim
CC: stdlib_json.nim
CC: ../../../../home/cristobal/.nimble/pkgs/clang-#head/clangpkg/Index.nim
CC: ../../../../home/cristobal/.nimble/pkgs/termstyle-0.1.0/termstyle.nim
CC: opir.nim
Hint:  [Link]
/usr/bin/ld: cannot find -lclang
collect2: error: ld returned 1 exit status
Error: execution of an external program failed: 'gcc   -o /tmp/nimble_23317/githubcom_PMunchfuthark/opir  /home/cristobal/.cache/nim/opir_r/stdlib_digitsutils.nim.c.o /home/cristobal/.cache/nim/opir_r/stdlib_assertions.nim.c.o /home/cristobal/.cache/nim/opir_r/stdlib_formatfloat.nim.c.o /home/cristobal/.cache/nim/opir_r/stdlib_dollars.nim.c.o /home/cristobal/.cache/nim/opir_r/stdlib_io.nim.c.o /home/cristobal/.cache/nim/opir_r/stdlib_system.nim.c.o /home/cristobal/.cache/nim/opir_r/stdlib_parseutils.nim.c.o /home/cristobal/.cache/nim/opir_r/stdlib_math.nim.c.o /home/cristobal/.cache/nim/opir_r/stdlib_algorithm.nim.c.o /home/cristobal/.cache/nim/opir_r/stdlib_strutils.nim.c.o /home/cristobal/.cache/nim/opir_r/stdlib_pathnorm.nim.c.o /home/cristobal/.cache/nim/opir_r/stdlib_times.nim.c.o /home/cristobal/.cache/nim/opir_r/stdlib_os.nim.c.o /home/cristobal/.cache/nim/opir_r/stdlib_hashes.nim.c.o /home/cristobal/.cache/nim/opir_r/stdlib_tables.nim.c.o /home/cristobal/.cache/nim/opir_r/stdlib_json.nim.c.o /home/cristobal/.cache/nim/opir_r/@m..@s..@s..@s..@shome@scristobal@s.nimble@spkgs@sclang-@hhead@sclangpkg@sIndex.nim.c.o /home/cristobal/.cache/nim/opir_r/@m..@s..@s..@s..@shome@scristobal@s.nimble@spkgs@stermstyle-0.1.0@stermstyle.nim.c.o /home/cristobal/.cache/nim/opir_r/@mopir.nim.c.o  -lm -lm -lrt  -lclang  -ldl'
    Prompt: Build failed for 'futhark@0.5.1', would you like to try installing 'futhark@#head' (latest unstable)? [y/N]
    Answer: 
     Error: Aborting installation due to build failure

This is my nim version:

Nim Compiler Version 1.6.5 [Linux: amd64]
Compiled at 2022-04-09
Copyright (c) 2006-2021 by Andreas Rumpf

git hash: d38177b11f628d9675809bfa85356c3ee3a26fea
active boot switches: -d:release

Ah, this is a packaging issue. On Ubuntu libclang and clang are two different packages, try installing libclang-dev and it should work

I already have libclang-dev installed 😕

$ sudo apt install libclang-dev
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
libclang-dev is already the newest version (1:13.0-53~exp1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

Ah right, Ubuntu tends to install packages in silly places. There is a dpkg command to list files installed by a package, use that to figure out where the so file named libclang is and then run LD_LIBRARY_PATH=/path/to/no/file nimble install futhark

Come to think of it I believe the path in the REAME with the passL flag is the correct one for Ubuntu

This is also a duplicate of #14

--passL and LD_LIBRARY_PATH didn't work for me.
maravilj's solutionl worked.
Thanks 🙃