Page 1 of 1

Calling script in c++ application

Posted: 11 Feb 2015, 10:15
by Peter Bezdek
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

Re: Calling script in c++ application

Posted: 11 Feb 2015, 11:38
by gawrilow
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);

Re: Calling script in c++ application

Posted: 11 Feb 2015, 15:38
by Peter Bezdek
mea culpa, i thought it is a script. It works now, thanks.