dibyendumajumdar / ravi

Ravi is a dialect of Lua, featuring limited optional static typing, JIT and AOT compilers
http://ravilang.github.io/
Other
1.16k stars 60 forks source link

libravi.so: cannot open shared object file: No such file or directory #205

Closed RussellHaley closed 3 years ago

RussellHaley commented 3 years ago

Hi,

osboxes@osboxes ~/git> git clone https://github.com/dibyendumajumdar/ravi.git
Cloning into 'ravi'...
remote: Enumerating objects: 243, done.
remote: Counting objects: 100% (243/243), done.
remote: Compressing objects: 100% (171/171), done.
remote: Total 13823 (delta 96), reused 154 (delta 70), pack-reused 13580
Receiving objects: 100% (13823/13823), 10.82 MiB | 5.71 MiB/s, done.
Resolving deltas: 100% (10531/10531), done.
osboxes@osboxes ~/git> cd ravi/
osboxes@osboxes ~/g/ravi (master)> ls
build-utils/    docker/   LICENSE              Makefile  patches/   ravi-config.h.in  ravi-env.linux.sh.in  README.rst    src/    vscode-debugger/
CMakeLists.txt  include/  lua-config.cmake.in  mir/      ravicomp/  ravi-env.bat.in   ravi-env.osx.sh.in    readthedocs/  tests/
osboxes@osboxes ~/g/ravi (master)> mkdir build-ninja
osboxes@osboxes ~/g/ravi (master)> cd build-ninja/
osboxes@osboxes ~/g/r/build-ninja (master)> cmake -GNinja ..
-- The C compiler identification is GNU 9.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- DYNAMIC library build enabled
-- Computed goto ON
-- Performing Test COMPILER_OPT_ARCH_NATIVE_SUPPORTED
-- Performing Test COMPILER_OPT_ARCH_NATIVE_SUPPORTED - Success
-- MIRJIT enabled
-- OS type is Linux
-- System processor is x86_64
-- Build type is 
-- Performing Test COMPILER_OPT_SIGNED_CHAR_SUPPORTED
-- Performing Test COMPILER_OPT_SIGNED_CHAR_SUPPORTED - Success
-- Performing Test COMPILER_OPT_NO_TREE_SRA_SUPPORTED
-- Performing Test COMPILER_OPT_NO_TREE_SRA_SUPPORTED - Success
-- Performing Test COMPILER_OPT_NO_IPA_CP_CLONE_SUPPORTED
-- Performing Test COMPILER_OPT_NO_IPA_CP_CLONE_SUPPORTED - Success
SOURCE dir is /home/osboxes/git/ravi/ravicomp
-- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY
-- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY - Success
-- Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY
-- Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY - Failed
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR - Success
-- Configuring done
-- Generating done
-- Build files have been written to: /home/osboxes/git/ravi/build-ninja
osboxes@osboxes ~/g/r/build-ninja (master)> ninja
[92/120] Building C object CMakeFiles/libravi.dir/src/ravi_mirjit.c.o
../src/ravi_mirjit.c: In function ‘mir_compile_C_module’:
../src/ravi_mirjit.c:367:55: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 4 has type ‘size_t’ {aka ‘long unsigned int’} [-Wformat=]
  367 |   snprintf(module_name, sizeof module_name, "__mod_%lld__", options->module_num);
      |                                                    ~~~^     ~~~~~~~~~~~~~~~~~~~
      |                                                       |            |
      |                                                       |            size_t {aka long unsigned int}
      |                                                       long long int
      |                                                    %ld
[120/120] Linking C executable ravi
osboxes@osboxes ~/g/r/build-ninja (master)> sudo ninja install
[0/1] Install the project...
-- Install configuration: ""
-- Installing: /usr/local/include/ravi/lua.h
-- Installing: /usr/local/include/ravi/luaconf.h
-- Installing: /usr/local/include/ravi/lualib.h
-- Installing: /usr/local/include/ravi/lauxlib.h
-- Installing: /usr/local/lib/libravi.so
-- Set runtime path of "/usr/local/lib/libravi.so" to ""
-- Installing: /usr/local/bin/ravi
-- Set runtime path of "/usr/local/bin/ravi" to ""
-- Installing: /usr/local/bin/ravidebug
-- Installing: /usr/local/bin/ravi_s
-- Installing: /usr/local/bin/ravi-env.sh
-- Installing: /usr/local/cmake/lua-config.cmake
-- Installing: /usr/local/lib/libc2mir.so
-- Installing: /usr/local/include/ravicomp/ravi_compiler.h
-- Installing: /usr/local/include/ravicomp/ravi_api.h
-- Installing: /usr/local/lib/libravicomp.so
-- Installing: /usr/local/include/ravicomp/ravicomp_export.h
osboxes@osboxes ~/g/r/build-ninja (master)> ravi
ravi: error while loading shared libraries: libravi.so: cannot open shared object file: No such file or directory
osboxes@osboxes ~/g/r/build-ninja (master) [127]> 

That build was inches away from being the most perfect build ever! Perhaps you've got a miss placed set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") ?

dibyendumajumdar commented 3 years ago

Hi

Thank you for the feedback!

The way I expect this to work is that you need to set the environment using ravi-env.sh script. The reason for this is that it also sets up other variables needed to locate Ravi/Lua scripts. Particularly important for Suravi.

I don't mind adding the RPATH setting as you suggest but it is not enough.

Regards

RussellHaley commented 3 years ago

I can't seem to make anything work for me. I've installed into a deploy folder in my build directory. The ravi-env.sh script is not executable and it assumes a bash shell (I use fish). When I source the file it destroys my path. Could you demonstrate how I would use ravi and the ravi-env.sh? A page number (RTM!) would be the best?

dibyendumajumdar commented 3 years ago

The steps I use (Ubuntu) are:

CMake:

cmake -DCMAKE_INSTALL_PREFIX=~/Software/ravi ..

After building and installing:

. ~/Software/ravi/bin/ravi-env.sh
RussellHaley commented 3 years ago

The ravi-env.sh nukes the path in my fish shell. But if I convert it over to fish syntax it works fine.

osboxes@osboxes ~/g/r/build-linux (master)> make install
[ 35%] Built target libravinojit_static
[ 39%] Built target testravidebug
[ 42%] Built target ravidebug
[ 44%] Built target ravi_s
[ 47%] Built target c2mir
[ 63%] Built target ravicomp
[ 99%] Built target libravi
[100%] Built target ravi
Install the project...
-- Install configuration: ""
-- Up-to-date: /home/osboxes/Software/ravi/include/ravi/lua.h
-- Up-to-date: /home/osboxes/Software/ravi/include/ravi/luaconf.h
-- Up-to-date: /home/osboxes/Software/ravi/include/ravi/lualib.h
-- Up-to-date: /home/osboxes/Software/ravi/include/ravi/lauxlib.h
-- Up-to-date: /home/osboxes/Software/ravi/lib/libravi.so
-- Up-to-date: /home/osboxes/Software/ravi/bin/ravi
-- Up-to-date: /home/osboxes/Software/ravi/bin/ravidebug
-- Up-to-date: /home/osboxes/Software/ravi/bin/ravi_s
-- Installing: /home/osboxes/Software/ravi/bin/ravi-env.sh
-- Up-to-date: /home/osboxes/Software/ravi/cmake/lua-config.cmake
-- Up-to-date: /home/osboxes/Software/ravi/lib/libc2mir.so
-- Up-to-date: /home/osboxes/Software/ravi/include/ravicomp/ravi_compiler.h
-- Up-to-date: /home/osboxes/Software/ravi/include/ravicomp/ravi_api.h
-- Up-to-date: /home/osboxes/Software/ravi/lib/libravicomp.so
-- Up-to-date: /home/osboxes/Software/ravi/include/ravicomp/ravicomp_export.h
osboxes@osboxes ~/g/r/build-linux (master)> cd ~
osboxes@osboxes ~> . ~/Software/ravi/bin/ravi-env.sh
COLORTERM truecolor
COMPIZ_CONFIG_PROFILE mate
DBUS_SESSION_BUS_ADDRESS unix:path=/run/user/1000/bus
DESKTOP_SESSION mate
DISPLAY :0
GDMSESSION mate
GDM_LANG en_US
GPG_AGENT_INFO /run/user/1000/gnupg/S.gpg-agent:0:1
GTK_MODULES appmenu-gtk-module:gail:atk-bridge:canberra-gtk-module
GTK_OVERLAY_SCROLLING 0
HOME /home/osboxes
LANG en_US.UTF-8
LANGUAGE en_US
LOGNAME osboxes
MATE_DESKTOP_SESSION_ID this-is-deprecated
PATH '/home/osboxes/Software/ravi/bin'  '/snap/bin'
PWD /home/osboxes
QT_ACCESSIBILITY 1
QT_AUTO_SCREEN_SCALE_FACTOR 0
QT_QPA_PLATFORMTHEME gtk2
QT_SCALE_FACTOR 1
RAVI_HOME /home/osboxes/Software/ravi
SESSION_MANAGER local/osboxes:@/tmp/.ICE-unix/1460,unix/osboxes:/tmp/.ICE-un…
SHELL /usr/bin/fish
SHLVL 1
SSH_AGENT_PID 1624
SSH_AUTH_SOCK /run/user/1000/keyring/ssh
TERM xterm-256color
UBUNTU_MENUPROXY 1
USER osboxes
VTE_VERSION 6003
WINDOWID 62914566
XAUTHORITY /home/osboxes/.Xauthority
XDG_CONFIG_DIRS /etc/xdg/xdg-mate:/etc/xdg
XDG_CURRENT_DESKTOP MATE
XDG_DATA_DIRS /usr/share/mate:/usr/local/share:/usr/share:/var/lib/snapd/d…
XDG_GREETER_DATA_DIR /var/lib/lightdm-data/osboxes
XDG_RUNTIME_DIR /run/user/1000
XDG_SEAT seat0
XDG_SEAT_PATH /org/freedesktop/DisplayManager/Seat0
XDG_SESSION_CLASS user
XDG_SESSION_DESKTOP mate
XDG_SESSION_ID c2
XDG_SESSION_PATH /org/freedesktop/DisplayManager/Session0
XDG_SESSION_TYPE x11
XDG_VTNR 7
osboxes@osboxes ~> ls
Command 'ls' is available in the following places
 * /bin/ls
 * /usr/bin/ls
The command could not be located because '/bin:/usr/bin' is not included in the PATH environment variable.
ls: command not found
/usr/share/fish/functions/ls.fish (line 11): 
    if command ls $opt / >/dev/null 2>/dev/null
               ^
from sourcing file /usr/share/fish/functions/ls.fish
in command substitution
Command 'ls' is available in the following places
 * /bin/ls
 * /usr/bin/ls
The command could not be located because '/bin:/usr/bin' is not included in the PATH environment variable.
ls: command not found
/usr/share/fish/functions/ls.fish (line 11): 
    if command ls $opt / >/dev/null 2>/dev/null
               ^
from sourcing file /usr/share/fish/functions/ls.fish
in command substitution
Command 'ls' is available in the following places
 * /bin/ls
 * /usr/bin/ls
The command could not be located because '/bin:/usr/bin' is not included in the PATH environment variable.
ls: command not found
/usr/share/fish/functions/ls.fish (line 11): 
    if command ls $opt / >/dev/null 2>/dev/null
               ^
from sourcing file /usr/share/fish/functions/ls.fish
in command substitution
Command 'ls' is available in the following places
 * /bin/ls
 * /usr/bin/ls
The command could not be located because '/bin:/usr/bin' is not included in the PATH environment variable.
ls: command not found
/usr/share/fish/functions/ls.fish (line 11): 
    if command ls $opt / >/dev/null 2>/dev/null
               ^
from sourcing file /usr/share/fish/functions/ls.fish
in command substitution
Command 'ls' is available in the following places
 * /bin/ls
 * /usr/bin/ls
The command could not be located because '/usr/bin:/bin' is not included in the PATH environment variable.
ls: command not found
Welcome to fish, the friendly interactive shell
Type `help` for instructions on how to use fish
osboxes@osboxes ~> . ~/Software/ravi/bin/ravi-env.fish 
osboxes@osboxes ~ [1]> ravi
Ravi 5.3.5
Copyright (C) 1994-2019 Lua.org, PUC-Rio
Portions Copyright (C) 2015-2020 Dibyendu Majumdar
Options assertions ltests mirjit
> ^C⏎                                                                                                                                                                                                              osboxes@osboxes ~ [SIGINT]> cat ~/Software/ravi/bin/ravi-env.fish 
set RAVI_HOME /home/osboxes/Software/ravi
set PATH $RAVI_HOME/bin:$PATH
set LD_LIBRARY_PATH $RAVI_HOME/lib:$LD_LIBRARY_PATH
set LUA_PATH "$RAVI_HOME/share/lua/5.3/?.lua;$RAVI_HOME/share/lua/5.3/?/init.lua;./?.lua;./?/init.lua"
set LUA_CPATH "$RAVI_HOME/lib/?.so;$RAVI_HOME/lib/lib?.so"

I'm good with this solution for now. Ravi is so cool. Well done!