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

Linker error when building project submodules: /usr/bin/ld: cannot find -lreadline #254

Open tsilia opened 9 months ago

tsilia commented 9 months ago

Hello.

I was building the @kunitoki/LuaBridge3 project with ravi as a submodule and stumbled upon a linker error:

[ 21%] Linking C executable ravi_s
[ 22%] Linking C executable testravidebug
/usr/bin/ld: cannot find -lreadline
collect2: error: ld returned 1 exit status
make[2]: *** [Tests/ravi/CMakeFiles/ravi_s.dir/build.make:85: Tests/ravi/ravi_s] Error 1
make[1]: *** [CMakeFiles/Makefile2:2515: Tests/ravi/CMakeFiles/ravi_s.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
/usr/bin/ld: cannot find -lreadline
collect2: error: ld returned 1 exit status
make[2]: *** [Tests/ravi/CMakeFiles/testravidebug.dir/build.make:115: Tests/ravi/testravidebug] Error 1
make[1]: *** [CMakeFiles/Makefile2:2461: Tests/ravi/CMakeFiles/testravidebug.dir/all] Error 2
/usr/bin/ld: CMakeFiles/LuaBridgeTests52LuaCNoexcept_DynamicLibrary.dir/Lua/LuaLibrary5.2.4.c.o: in function `os_tmpname':
LuaLibrary5.2.4.c:(.text+0x9a79): warning: the use of `tmpnam' is dangerous, better use `mkstemp'
[ 22%] Linking C executable ravidebug
[ 22%] Built target LuaBridgeTests52LuaCNoexcept_DynamicLibrary
[ 22%] Linking CXX shared library libLuaBridgeTests53LuaC_DynamicLibrary.so
/usr/bin/ld: cannot find -lreadline
collect2: error: ld returned 1 exit status
make[2]: *** [Tests/ravi/CMakeFiles/ravidebug.dir/build.make:115: Tests/ravi/ravidebug] Error 1
make[1]: *** [CMakeFiles/Makefile2:2488: Tests/ravi/CMakeFiles/ravidebug.dir/all] Error 2
/usr/bin/ld: CMakeFiles/LuaBridgeTests53LuaC_DynamicLibrary.dir/Lua/LuaLibrary5.3.6.c.o: in function `os_tmpname':
LuaLibrary5.3.6.c:(.text+0x9f5f): warning: the use of `tmpnam' is dangerous, better use `mkstemp'
[ 22%] Built target LuaBridgeTests53LuaC_DynamicLibrary
Scanning dependencies of target liblua-static
[ 22%] Linking C shared library libravi.so
/usr/bin/ld: cannot find -lreadline
collect2: error: ld returned 1 exit status
make[2]: *** [Tests/ravi/CMakeFiles/libravi.dir/build.make:701: Tests/ravi/libravi.so] Error 1
make[1]: *** [CMakeFiles/Makefile2:2599: Tests/ravi/CMakeFiles/libravi.dir/all] Error 2

Looks like the build script won't check all necessary dependencies at the configure stage. I had to install the libreadline-dev package, which solved the issue for me.

First I reported this here: https://github.com/kunitoki/LuaBridge3/issues/156 but it seems that it's not LuaBridge3 but ravi which requires libreadline as a dependency.

dibyendumajumdar commented 9 months ago

hi @tsilia Thank you for the report. Was there a specific action you recommend, apart from updating build instructions?

tsilia commented 9 months ago

Hello @dibyendumajumdar

Thank you for your reply.

If you could implement a detection of the readline development package on the build system in your CMake build script, that would be great. This way user will be notified they don't have the required dependency at the configure stage. But I can't suggest anything regarding the matter as I'm not familiar with the readline library. I don't know what build system it uses and whether it can be detected via CMake rules or not. And I don't have anything else in mind, TBH.

UPD: I'm not a CMake guru, but I just thought you probably could use simple detection technique: CHECK_INCLUDE_FILE(<include> <variable> [<flags>]) like this:

CHECK_INCLUDE_FILE(readline.h HAVE_READLINE)

or whatever header file it is that the readline library has.

dibyendumajumdar commented 9 months ago

Okay thank you - I will look at making the Cmake build more robust