[Ipopt] Trying to run IPOPT C++ example

Chintan Pathak cp84 at uw.edu
Thu Aug 24 21:40:45 EDT 2017


Hi Alex,

While I am still having issues with running the C++ executable, I can see a
few errors in your approach:

1. You will need the hs071_nlp.cpp (file containing the NLP implementation
etc), hs071_nlp.hpp, hs071_main.cpp (file containing main, ipopt object
etc.)
2. Once you have that, the correct syntax for compilation is:

C:\MinGW\bin\g++ -std=c++11 -DHAVE_CONFIG_H -o outputgpp.exe  hs071_nlp.cpp
hs071_main.cpp -I"C:\Ipopt\3.11.2\include" -L"C:\Ipopt\3.11.2\lib" -lIpopt

Let me decode the various parts:

1, C:\MingGW\bin\g++ : is the path to my compiler, this can be different
for you. Make sure this matches the bitness of the installed library
though, 32-bit or 64-bit.
2. -std=c++11 : You are already using this flag, for compatibility with
C++11
3. -DHAVE_CONFIG_H : This is a preprocessor macro needed to avoid the error:
'FORTRAN_INTEGER_TYPE' does not name a type typedef FORTRAN_INTEGER_TYPE
ipfint;
4. -o output.exe : Name of executable, on linux you wont need .exe
5. hs071 ... : All the C++ files you want to compile together.
6. -I : path to include files
7. -L : path to library
8 -lIpopt : The actual libraries to be included

You are missing the last two flags.

Let me know if this works or not.

Thanks
Chintan Pathak



https://about.me/chintanpathak

On Wed, Aug 23, 2017 at 7:26 PM, Alexander Martinez-Marchese <
alex.martinezmarchese at outlook.com> wrote:

> Hi,
>
>
>       I'm trying to run the C++ example described here:
>
>
> https://www.coin-or.org/Ipopt/documentation/node23.html
> <https://urldefense.proofpoint.com/v2/url?u=https-3A__www.coin-2Dor.org_Ipopt_documentation_node23.html&d=DwMFAw&c=Ngd-ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=EWqK7Xwyv36yJwUbXtvDBg&m=6yM-yfHCCrtJ8OZbSRQDhklOFM-iSrYBEdGZxMPl9_U&s=38hRoQg2Hhh5ZcyRi6uHr-8WF_Ix3rTuSDLNw6sF1MQ&e=>
>
>
>
> So I copied the files myexample.cpp, hs071_nlp.cpp and hs071_nlp.cpp and I
> run the following in the terminal (within Ubuntu linux):
>
>
> c++ -std=c++11 myexample.cpp hs071_nlp.cpp -o myexample -I
> /home/alex/Ipopt-3.12.8/include/coin
>
>
> And I get the following error:
>
>
> /tmp/ccIUQtXB.o: In function `main':
> myexample.cpp:(.text+0x52): undefined reference to
> `IpoptApplicationFactory'
> collect2: error: ld returned 1 exit status
>
>
>
> I tested my IPOPT installation using 'make test' and I get this:
>
>
> Running unitTests...
> Testing AMPL Solver Executable...
>     no AMPL solver executable found, skipping test...
> Testing C++ Example...
>     Test passed!
> Testing C Example...
>     Test passed!
> Testing Fortran Example...
>     Test passed!
> make[2]: Leaving directory '/home/alex/Ipopt-3.12.8/Ipopt/test'
> make[1]: Leaving directory '/home/alex/Ipopt-3.12.8/Ipopt'
>
> Do I need AMPL for the example? Am I linking the files correctly? Is there
> a 'bare bones' C++ example that doesn't use smart pointers or the
> IpoptApplicationFactory?
>
>
> I am able to use IPOPT from pyipopt to solve l-bfgs-b problems. The IPOPT
> installation was installed with the HSL files:
> http://www.hsl.rl.ac.uk/ipopt/
> <https://urldefense.proofpoint.com/v2/url?u=http-3A__www.hsl.rl.ac.uk_ipopt_&d=DwMFAw&c=Ngd-ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=EWqK7Xwyv36yJwUbXtvDBg&m=6yM-yfHCCrtJ8OZbSRQDhklOFM-iSrYBEdGZxMPl9_U&s=04wqPIYe1e-vYRqgwq1cWTBKKdSbU_hNPm1jJJuAxg4&e=>
>
>
>
> Thank you,
>
> Alex
>
>
>
>
>
> _______________________________________________
> Ipopt mailing list
> Ipopt at list.coin-or.org
> https://urldefense.proofpoint.com/v2/url?u=https-3A__list.
> coin-2Dor.org_mailman_listinfo_ipopt&d=DwICAg&c=Ngd-
> ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=EWqK7Xwyv36yJwUbXtvDBg&m=6yM-
> yfHCCrtJ8OZbSRQDhklOFM-iSrYBEdGZxMPl9_U&s=bX1ii9JL_
> PyycsY_Ir0kukOwGwWEEwVrc8oqc-TFf50&e=
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.coin-or.org/pipermail/ipopt/attachments/20170824/766076e1/attachment.html>


More information about the Ipopt mailing list