Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
tsilia opened this issue Nov 15, 2023 · 3 comments

Comments

@tsilia
Copy link

tsilia commented Nov 15, 2023

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:
kunitoki/LuaBridge3#156
but it seems that it's not LuaBridge3 but ravi which requires libreadline as a dependency.

@dibyendumajumdar
Copy link
Owner

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

@tsilia
Copy link
Author

tsilia commented Nov 22, 2023

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
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants