C++ and AMPL

63 views
Skip to first unread message

Samuele Viaro

unread,
Sep 30, 2021, 1:33:23 PM9/30/21
to am...@googlegroups.com
Hello,
I am trying to create a .cpp file (MyFile.cpp) that calls ampl and solves a code, but I cannot seem to be able to compile it.
I am using the following
gcc -I <ampl.h path> MyFile.cpp -o output-program -L <libampl.so path> -lampl

any suggestions?
I would like to create my own makefile instead of usinc cmake...

Thank you
Sam



AMPL Google Group

unread,
Sep 30, 2021, 2:09:25 PM9/30/21
to AMPL Modeling Language
Hi Sam,

Inside amplapi/examples/cpp, you should be able to compile firstexample.cc as follows:

$ g++ -std=c++11 -Wall -o firstexample firstexample.cc -I../../include -L../../lib -lampl
$ LD_LIBRARY_PATH=$LD_LIBRARY_PATH:../../lib ./firstexample


--
Filipe Brandão
am...@googlegroups.com
{#HS:1646828716-106495#}
--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ampl+uns...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ampl/CAPsAHM%2B3fwv92WB6snqVj6jfcGjrcWCe%2Bzj4ozC1c5%2BxHicmyQ%40mail.gmail.com.

Reply all
Reply to author
Forward
0 new messages