(Redis) Cannot find asio in CMakeLists.txt

This isn’t really a stage problem, but before heading any further into testing, I wanted to check why asio isn’t found on my computer.

I get this CMake error upon reloading it locally:

CMake Error at CMakeLists.txt:11 (find_package):
  Could not find a package configuration file provided by "asio" with any of
  the following names:

    asioConfig.cmake
    asio-config.cmake

  Add the installation prefix of "asio" to CMAKE_PREFIX_PATH or set
  "asio_DIR" to a directory containing one of the above files.  If "asio"
  provides a separate development package or SDK, be sure it has been
  installed.

I am building this using WSL on Ubuntu 22.04, so if anyone knows a fix for this, it would be greatly appreciated

For now, I used an external repository to fix this error

1 Like

Hey @fortwoone, glad to hear you’ve resolved the issue!

You might also find this approach helpful:

Hi, I’m also running into this issue (on Ubuntu 20.04). I installed vcpkg, exported VCPKG_ROOT, and installed the packages:

work@silent:~/codecrafters/codecrafters-redis-cpp$ echo $VCPKG_ROOT
/home/work/bin/vcpkg
work@silent:~/codecrafters/codecrafters-redis-cpp$ ls -l $VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake
-rw-rw-r-- 1 work work 47875 Oct  5 21:07 /home/work/bin/vcpkg/scripts/buildsystems/vcpkg.cmake
work@silent:~/codecrafters/codecrafters-redis-cpp$ ${VCPKG_ROOT}/vcpkg install
Detecting compiler hash for triplet x64-linux...
Compiler found: /usr/bin/c++
The following packages are already installed:
    asio:x64-linux@1.30.2 -- git+https://github.com/microsoft/vcpkg@17ce1a2d17d0cb0d50eb72c89a9e51f472ef31f4
    pthreads:x64-linux@3.0.0#14 -- git+https://github.com/microsoft/vcpkg@2e0a6df2800d3677b941dc6504f083965b7886d9
  * vcpkg-cmake:x64-linux@2023-05-04 -- git+https://github.com/microsoft/vcpkg@88a7058fc7fa73a9c4c99cfcae9d79e2abf87a5a
  * vcpkg-cmake-config:x64-linux@2022-02-06#1 -- git+https://github.com/microsoft/vcpkg@8d54cc4f487d51b655abec5f9c9c3f86ca83311f
asio provides CMake targets:

  # this is heuristically generated, and may not be correct
  find_package(asio CONFIG REQUIRED)
  target_link_libraries(main PRIVATE asio::asio)

All requested installations completed successfully in: 123 us

(packages are already installed because I re-ran the command).

I’m still running into the error with asio:

work@silent:~/codecrafters/codecrafters-redis-cpp$ cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake
CMake Error at CMakeLists.txt:11 (find_package):
  Could not find a package configuration file provided by "asio" with any of
  the following names:

    asioConfig.cmake
    asio-config.cmake

  Add the installation prefix of "asio" to CMAKE_PREFIX_PATH or set
  "asio_DIR" to a directory containing one of the above files.  If "asio"
  provides a separate development package or SDK, be sure it has been
  installed.


-- Configuring incomplete, errors occurred!
See also "/home/work/codecrafters/codecrafters-redis-cpp/build/CMakeFiles/CMakeOutput.log".
See also "/home/work/codecrafters/codecrafters-redis-cpp/build/CMakeFiles/CMakeError.log".

The CMakeLists.txt:11 line is find_package(asio CONFIG REQUIRED).

Hey @deer-314, I just tested your code on Ubuntu 24.04 but wasn’t able to reproduce the same error.

Could you share the contents of ~/codecrafters/codecrafters-redis-cpp/build/vcpkg_installed/x64-linux/share/asio/ on your end?

Here’s what mine looks like:

$ ls build/vcpkg_installed/x64-linux/share/asio/
asio-config.cmake  [other files]

Closing this thread due to inactivity. If you still need assistance, feel free to reopen or start a new discussion!

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