CMake can't find installed package

I often have lots of trouble getting CMake to accept that I do in fact have some package installed and it's because I don't understand what info to give to CMake and/or how to do that.

For example, I've installed libnest2d through apt install libnlopt-dev.

However, when I run the CMake from pynest2d, it still complains that it cannot find it:

CMake Error at /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message): NLopt library cannot be found. Consider set NLopt_PATH environment variable (missing: NLopt_INCLUDE_DIRS)
Call Stack (most recent call first): /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393 (_FPHSA_FAILURE_MESSAGE) cmake/FindNLopt.cmake:63 (find_package_handle_standard_args) CMakeLists.txt:15 (find_package)

I get this quite often when compiling & installing, but I'm not really sure what it wants me to do about it. I've tried locating the library myself, but then I always end up with loads of possible directories and I'm not sure what to even do with those directories if I manage to find the correct one.

What files is CMake looking for specifically?

How do I tell CMake (preferably via cmake-gui) to look at the directory where I know those file to be?

Here's all of the directories which could be candidates to provide to CMake.

$ locate libnlopt-dev
/usr/share/doc/libnlopt-dev
/var/lib/dpkg/info/libnlopt-dev:amd64.list
/var/lib/dpkg/info/libnlopt-dev:amd64.md5sums
$ dpkg -L libnlopt-dev
/.
/usr
/usr/include
/usr/include/nlopt.f
/usr/include/nlopt.h
/usr/lib
/usr/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu/cmake
/usr/lib/x86_64-linux-gnu/cmake/nlopt
/usr/lib/x86_64-linux-gnu/cmake/nlopt/NLoptConfig.cmake
/usr/lib/x86_64-linux-gnu/cmake/nlopt/NLoptConfigVersion.cmake
/usr/lib/x86_64-linux-gnu/cmake/nlopt/NLoptLibraryDepends-none.cmake
/usr/lib/x86_64-linux-gnu/cmake/nlopt/NLoptLibraryDepends.cmake
/usr/lib/x86_64-linux-gnu/pkgconfig
/usr/lib/x86_64-linux-gnu/pkgconfig/nlopt.pc
/usr/share
/usr/share/doc
/usr/share/man
/usr/share/man/man3
/usr/share/man/man3/nlopt.3.gz
/usr/share/man/man3/nlopt_minimize.3.gz
/usr/share/man/man3/nlopt_minimize_constrained.3.gz
/usr/lib/x86_64-linux-gnu/libnlopt.so
/usr/share/doc/libnlopt-dev

I'm currently on XFCE4 in WSL2.

1 Answer

in file pynest2d/cmake/FindNLopt.cmake in the call find_path(NLopt_INCLUDE_DIRS ..) you may need to modify the file name fromm nlopt.hpp to nlopt.h

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like