Calling script in c++ application

Questions and problems about using polymake go here.
Peter Bezdek
Posts: 3
Joined: 11 Feb 2015, 09:49

Calling script in c++ application

Postby Peter Bezdek » 11 Feb 2015, 10:15

Hello,

I am using polymake library in my c++ application and I encounter a problem when trying to call script (for example "gc_closure") within c++ code.

Code: Select all

#include <polymake/Main.h> #include <polymake/Matrix.h> #include <polymake/SparseMatrix.h> #include <polymake/Rational.h> using namespace polymake; int main(int argc, const char* argv[]) { try { Main pm; pm.set_application("polytope"); perl::Object p("Polytope<Rational>"); perl::Object pp("Polytope<Rational>"); int m=3; int n=3; polymake::Matrix<Rational> mat(m,n); polymake::Rational* elem = concat_rows(mat).begin(); Rational values[] = {1,1,0, 1,3,0, 1,2,1.5}; for(int i = 0; i<m*n; ++i) { *(elem+i) = *(values+i); } p.take("VERTICES") << mat ; pp = CallPolymakeFunction("script", "gc_closure", p); } catch (const std::exception& ex) { std::cerr << "ERROR: " << ex.what() << endl; return 1; } return 0; }
When running this c++ example I get following error message: ERROR: script file "gc_closure" not found.
When running interactive polymake from shell, there is no problem and scripts are working as expected.

Do I need to modify standard compilation process of my c++ application somehow in order to be able to use scripts? Do you have any suggestion?

Thank you very much.
Peter

User avatar
gawrilow
Main Author
Posts: 423
Joined: 25 Dec 2010, 17:40

Re: Calling script in c++ application

Postby gawrilow » 11 Feb 2015, 11:38

gc_closure is not a script, it's a C++ function, at least in the current snapshot. You should call it directly, without "script":

Code: Select all

CallPolymakeFunction("gc_closure", p);

Peter Bezdek
Posts: 3
Joined: 11 Feb 2015, 09:49

Re: Calling script in c++ application

Postby Peter Bezdek » 11 Feb 2015, 15:38

mea culpa, i thought it is a script. It works now, thanks.


Return to “Helpdesk”