Use CasADi in VS2017

148 views
Skip to first unread message

pablope...@gmail.com

unread,
Feb 19, 2019, 6:24:31 AM2/19/19
to CasADi
Hello,

I am trying to port some of my programs fom python language to c++ using VS2017. I have tried to use my current packages installed in the Python37 folder but I am getting linking errors while compiling.

I have configured "C:\Program Files\Python37\Lib\site-packages\casadi\include" as the inclusion folder, but the problem comes when I tied to find libraries: I can not find any *.lib files related with CasADi, only the *.dll. I have tried also to download the matlab and the python zip versions, but not able to find .lib anywhere. I wonder if I am missing something or it is supposusse I must use cmake to build the .libs?

Thank you,
Pablo

Joris Gillis

unread,
Feb 19, 2019, 8:32:50 AM2/19/19
to CasADi
Dear Pablo,

We do not currently ship Visual-Studio compatible libraries.
All our official binaries are prepared with MinGW.

Your best bet is to build CasADi yourself using Visual Studio.

Best regards,
  Joris

pablope...@gmail.com

unread,
Feb 19, 2019, 11:10:59 AM2/19/19
to CasADi
Thank you very much, Joris.

I have already compiled with CMake + VS2017 and now I am able to link the libs and run programs.

My current problem is trying to call Ipopt solver, where I get an exception everytime I try to use it with < nlpsol("solver", "ipopt", nlp) >.
I guess I should compile Ipopt within CasADi dll, but compiling Ipopt is kind of daunting task. I wonder if CasADi is able to call Ipopt using an external Ipopt binary previously compiled, in the same way that Ampl, Pyomo... do.

Can you tell me if Is this possible?

Joris Gillis

unread,
Feb 19, 2019, 11:46:36 AM2/19/19
to CasADi
Dear Pablo,

In principle, I don't see any issue with calling an external ipopt.
In fact, ipopt is not in our build system, so you'd always be using external ipopt libraries.
Do make sure that your Ipopt libraries are build with the same version (and patchlevel?) of VS:
Ipopt is a C++ interface; and these are fragile for VS..

Best regards,
  Joris

pablope...@gmail.com

unread,
Feb 19, 2019, 12:32:18 PM2/19/19
to CasADi
Sorry again, but I am not really sure of your building chain and ABI compatibily.

In my current python downloaded package from pip I find the library "libcasadi_nlpsol_ipopt.dll", but in the project I have created I am not finding it. Changing CMake and setting WITH_IPOPT value I get an error telling me about not finding Ipopt include and lib folders, that is right:

Checking for one of the modules 'ipopt'

CMake Error at C:/cmake-3.13.4-win64-x64/share/cmake-3.13/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
Could NOT find IPOPT (missing: IPOPT_LIBRARIES IPOPT_INCLUDE_DIRS)
Call Stack (most recent call first):
C:/cmake-3.13.4-win64-x64/share/cmake-3.13/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
cmake/FindIPOPT.cmake:35 (find_package_handle_standard_args)
CMakeLists.txt:618 (find_package)


But I don't want to compile Ipopt, so it was my question about using an external executable. In Pyomo and AMPL I used the AMPL free distributed binaries of this solver (ipopt.exe + libipoptfort.dll).


Now I have two questions:

1) Where is located CasADi binaries for Ipopt that are distributed with pip?

2) In order to use c++ CasADi with VS must I compile Ipopt as a dll or might I just keep using the third party previously compiled binaries?

Joris Gillis

unread,
Feb 19, 2019, 12:38:52 PM2/19/19
to CasADi
Dear Pablo,

Our binaries are useless for your present task, please ignore them.

Your best bet is to look for Ipopt libraries that are built with your version of VS, and make the CasADi build system locate those.
I could imagine coinor provides these binaries or perhaps pyomo..

Best,
Joris

Joris Gillis

unread,
Feb 19, 2019, 12:46:40 PM2/19/19
to CasADi
CasADi can only use ipopt in the form of a library. An executable is not supported..

Christopher Dembia

unread,
Feb 19, 2019, 1:42:34 PM2/19/19
to Joris Gillis, CasADi
Pablo:

I have successfully used the following Ipopt binary that I built using flang on Windows:


To make use of this binary, you should use my branch of CasADi: https://github.com/chrisdembia/casadi/tree/msvc_ipopt

I’m hoping to work with Joris/Joel to get these changes merged into CasADi.

On Feb 19, 2019, at 9:46 AM, Joris Gillis <joris.g...@gmail.com> wrote:

CasADi can only use ipopt in the form of a library. An executable is not supported..

--
Sent from CasADi's user forum at http://forum.casadi.org.
---
You received this message because you are subscribed to the Google Groups "CasADi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to casadi-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/casadi-users/6815fe61-5e62-4219-be8b-c6ecde669c18%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

pablope...@gmail.com

unread,
Feb 20, 2019, 11:55:17 AM2/20/19
to CasADi
Thanks a lot for sharing your time and your work, Chris.

I have download both of your packages and still having problems with CMake.
I uncompress both folders, and then I run CMake. I create a build folder in your casadi brank folder.
I set up the WITH_IPOPT flag and set the route to Ipopt_DIR as C:\Ipopt (the folder uncompress previously where it is located bin+include+lib).

I try to configure CMake  but still receiving the same error that i exposed here yesterday.

Any help about this? Am I doing anything wrong? Should I copy Ipopt folder in an specific place within the Casadi project?

Thank you very much.

Anand jv

unread,
Nov 25, 2019, 6:07:59 AM11/25/19
to CasADi
Dear Pablo,

I am trying to build the casadi from source for a MSVC project. I figured out how to do that and now stuck up with integrating the IPOPT solver interfaces/binaries into the existing project. I bumped into this post (although pretty old) and discovered that I am exactly in the same step as posted by you. Did you manage to figure out a way to integrate the binaries from IPOPT into your project. If so, could you please let me know some steps on how to do that and where/what to change in the existing project. 
Any help on this will really be appreciated. 

Thanks and Regards,
Anand
Reply all
Reply to author
Forward
0 new messages