Search code examples
windows-subsystem-for-linuxnlopt

Nlopt libraries not find on Ubuntu (WSL)


I've installed the NLOPT library using apt and also from the source :

git clone git://github.com/stevengj/nlopt
cd nlopt
mkdir build
cd build
cmake ..
make
sudo make install

The problem is when trying to compile an open-source project with CMake calling NLOPT, I get this error :

Could NOT find Nlopt (missing: NLOPT_LIBRARY NLOPT_LIBRARIES)

However when I list the directory '/usr/local/include' , I find the files nlopt.f nlopt.h nlopt.hpp

Also , I tried to add before the line 'find_package(NLOPT REQUIRED)' located in the CMakeLists the command ' SET(NLOPT_LIBRARY "/usr/local/lib/nlopt.so"). However, I don't know what to associate to the variable NLOPT_LIBRARIES ? Any help please?


Solution

  • I solved the isse with adding into the CMakeList.txt of the project the following lines

    SET(NLOPT_LIBRARY "/usr/local/lib/libnlopt.so")
    SET(NLOPT_LIBRARIES "/usr/local/lib/libnlopt.so.0" "/usr/local/lib/libnlopt.so.0.10.0")
    

    I hope it will be useful to others.