# How can i use readline instead

**URL:** <https://forum.codecrafters.io/t/how-can-i-use-readline-instead/6947>\
**Category:** Challenges\
**Tags:** challenge:shell\
**Created:** [March 17, 2025, 12:55am UTC](https://forum.codecrafters.io/t/how-can-i-use-readline-instead/6947 "2025-03-17T00:55:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![zakaria-didah](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/zakaria-didah/32/7106_2.png) [@zakaria-didah](https://forum.codecrafters.io/u/zakaria-didah)\
**Post date:** [March 17, 2025, 12:55am UTC](https://forum.codecrafters.io/t/how-can-i-use-readline-instead/6947/1 "2025-03-17T00:55:44Z")

</div>

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`.

```auto
/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.

```

---

<div class="post-metadata">

**Author:** ![zakaria-didah](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/zakaria-didah/32/7106_2.png) [@zakaria-didah](https://forum.codecrafters.io/u/zakaria-didah)\
**Post date:** [March 17, 2025, 1:01am UTC](https://forum.codecrafters.io/t/how-can-i-use-readline-instead/6947/2 "2025-03-17T01:01:10Z")

</div>

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

```auto
/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.

```

---

<div class="post-metadata">

**Author:** ![andy1li](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/andy1li/32/10_2.png) [@andy1li](https://forum.codecrafters.io/u/andy1li)\
**Post date:** [March 17, 2025, 6:21am UTC](https://forum.codecrafters.io/t/how-can-i-use-readline-instead/6947/4 "2025-03-17T06:21:11Z")

</div>

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

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

```

 ![image](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/2X/f/f1ae138e4461039600a4b7fec552161509d3d5af.png)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/3X/7/0/700657133935c15703e22c7c8870394f6e6dc27d.svg) [@system](https://forum.codecrafters.io/u/system)\
**Post date:** [March 22, 2025, 6:21am UTC](https://forum.codecrafters.io/t/how-can-i-use-readline-instead/6947/6 "2025-03-22T06:21:14Z")

</div>

Closed on March 22, 2025, 6:21am UTC

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