coin-or / SHOT

A solver for mixed-integer nonlinear optimization problems
https://shotsolver.dev
Eclipse Public License 2.0
115 stars 24 forks source link

building SHOT with CMAKE and MSVC #140

Open jbensabat opened 2 years ago

jbensabat commented 2 years ago

Hello I am trying to build SHOT with CMAKE GUI and MSVC First I build CBC and the dependencies, brought a compiled version of IPOPT (MSVC 2019) in CMAKE GUI I get the following errors

Selecting Windows SDK version 10.0.17763.0 to target Windows 10.0.19042. CMake Error at CMakeLists.txt:88 (file): file FILE([TO_CMAKE_PATH|TO_NATIVE_PATH] path result) must be called with exactly three arguments.

CMake Error at CMakeLists.txt:89 (file): file FILE([TO_CMAKE_PATH|TO_NATIVE_PATH] path result) must be called with exactly three arguments.

Git hash: n/a Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE) -- Searching for Cbc libraries and its dependencies, e.g. in C:\MINLP\CBC/lib/ Cbc library found at: C:/MINLP/CBC/MSVisualStudio/v16/x64/Debug/libCbc.lib CbcSolver library found at: C:/MINLP/CBC/MSVisualStudio/v16/x64/Debug/libCbcSolver.lib OsiClp library found at: C:/MINLP/CBC/MSVisualStudio/v16/x64/Debug/libOsiClp.lib Clp library found at: C:/MINLP/CLP/MSVisualStudio/v16/x64/Debug/libClp.lib Osi library found at: C:/MINLP/CBC/MSVisualStudio/v16/x64/Debug/libOsi.lib CoinUtils library found at: C:/MINLP/COINUTILS/MSVisualStudio/v16/libCoinUtils/x64/Debug/libCoinUtils.lib Cgl library found at: C:/MINLP/CGL/MSVisualStudio/v16/x64/Debug/libCgl.lib

Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE) Checking for one of the modules 'ipopt' CMake Error at C:/Program Files/CMake/share/cmake-3.21/Modules/FindPkgConfig.cmake:849 (message): None of the required 'ipopt' found Call Stack (most recent call first): CMakeLists.txt:251 (pkg_search_module)

-- Cbc include files will be used from: C:\MINLP\CBC\src -- The following Cbc libraries will be used from: C:/MINLP/CBC/MSVisualStudio/v16/x64/Debug/libCbc.lib;C:/MINLP/CBC/MSVisualStudio/v16/x64/Debug/libCbcSolver.lib;C:/MINLP/CBC/MSVisualStudio/v16/x64/Debug/libOsiClp.lib;C:/MINLP/CLP/MSVisualStudio/v16/x64/Debug/libClp.lib;C:/MINLP/CBC/MSVisualStudio/v16/x64/Debug/libOsi.lib;C:/MINLP/COINUTILS/MSVisualStudio/v16/libCoinUtils/x64/Debug/libCoinUtils.lib;C:/MINLP/CGL/MSVisualStudio/v16/x64/Debug/libCgl.lib -- Ipopt include files will be used from: C:\MINLP\IPOPT\bin/include/coin -- The following Ipopt libraries will be used from:

CMake Error at CMakeLists.txt:664 (install): install TARGETS given target "SHOT" which does not exist.

Configuring incomplete, errors occurred! See also "C:/MINLP/SHOT/build/CMakeFiles/CMakeOutput.log".

It seems that it does not find ipopt (there is no directory for the lib or any other input form) and also this error that appears twice:

file FILE([TO_CMAKE_PATH|TO_NATIVE_PATH] path result) must be called with exactly three arguments.

any help would really be appreciated thanks jac

jbensabat commented 2 years ago

I am more precise now the script uses pkg-config.exe which is not present in windows. It uses it twice: 1) for the detection of ipopt 2) for the determination of the target locations. I commented these two and manages to build now I need to add ipopt functionality somehow outside CMAKE any idea would be welcome best jac

andreaslundell commented 2 years ago

I have actually never tried to build SHOT with MSVC, but in principle it should be possible (with some manual work). I would suggest you look into the *.pc files in the lib/pkgconfig directory that is hopefully part of the compiled Ipopt distribution you downloaded. There there are flags for what to include, linker flags needed, etc.

Then you can just substitute these values manually into the ${IPOPT_*} variables in SHOT's CMakeLists.txt file.

Pkgconfig actually just uses the values in the *.pc files to automatically figure out how to include Ipopt when compiling.

Please let me know if you manage to get this working, then I could perhaps add a note about this to the documentation.

If you are using SHOT to solve convex problems, you could also try to compile SHOT without Ipopt. This is possible in the master branch and SHOT version 1.1 beta by setting HAS_IPOPT to false.

Another option is to use WSL on Windows...

jbensabat commented 2 years ago

hi thanks for your message. What I am trying to do is to include ipopt directly in the MSVC environment and the same with the targets I shall test everything and if it works I will post a description of what I have done another way to overcome this issue is to use find_package() instead. I have no experience in developing cmake apps so .. best jac