How can i use readline instead

i’m new to this platform, how can i use other func or other libraries like readline. or how to edit the compilation so i can include -lreadline.

/usr/bin/ld: CMakeFiles/shell.dir/src/main.c.o: in function `main':
remote: [compile] main.c:(.text+0x205): undefined reference to `readline'
remote: [compile] collect2: error: ld returned 1 exit status
remote: [compile] gmake[2]: *** [CMakeFiles/shell.dir/build.make:817: shell] Error 1
remote: [compile] gmake[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/shell.dir/all] Error 2
remote: [compile] gmake: *** [Makefile:91: all] Error 2
remote: [compile] Looks like your code failed to compile.
remote: [compile] If you think this is a CodeCrafters error, please let us know at hello@codecrafters.io.

i’m new to this platform. how can i use the readline instead. or how can i edit the compilation part.

/usr/bin/ld: CMakeFiles/shell.dir/src/main.c.o: in function `main':
remote: [compile] main.c:(.text+0x205): undefined reference to `readline'
remote: [compile] collect2: error: ld returned 1 exit status
remote: [compile] gmake[2]: *** [CMakeFiles/shell.dir/build.make:817: shell] Error 1
remote: [compile] gmake[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/shell.dir/all] Error 2
remote: [compile] gmake: *** [Makefile:91: all] Error 2
remote: [compile] Looks like your code failed to compile.
remote: [compile] If you think this is a CodeCrafters error, please let us know at hello@codecrafters.io.

Hey @zakaria-didah, our tester uses vcpkg, so you can add the following lines to CMakeLists.txt to properly link readline:

find_package(PkgConfig REQUIRED)
pkg_check_modules(READLINE REQUIRED readline)
target_link_libraries(shell PRIVATE ${READLINE_LIBRARIES})

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.