Callable library, Hasse diagram

Questions and problems about using polymake go here.
pfetsch
Posts: 4
Joined: 24 Apr 2013, 19:23

Callable library, Hasse diagram

Postby pfetsch » 24 Apr 2013, 19:28

The code below does not compile:

smalltest2.o: In function `pm::perl::Value::operator polymake::graph::HasseDiagram<polymake::graph::HasseDiagram>() const':
smalltest2.cc:(.text._ZNK2pm4perl5ValuecvT_IN8polymake5graph12HasseDiagramEEEv[pm::perl::Value::operator polymake::graph::HasseDiagram<polymake::graph::HasseDiagram>() const]+0x3c): undefined reference to `polymake::graph::operator>>(pm::perl::Value const&, polymake::graph::HasseDiagram&)'

Any clue?

Code: Select all

#include <polymake/Main.h> #include <polymake/graph/HasseDiagram.h> using namespace polymake; int main(int argc, const char* argv[]) { try { const int dim = 4; Main pm; pm.set_application("topaz"); perl::Object p("SimplicialComplex"); p = CallPolymakeFunction("load", "test.top"); graph::HasseDiagram HD = p.give("HASSE_DIAGRAM"); } catch (const std::exception& ex) { std::cerr << "ERROR: " << ex.what() << endl; return 1; } return 0; }

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

Re: Callable library, Hasse diagram

Postby gawrilow » 24 Apr 2013, 23:36

The same problem has already been discussed in another thread. Be sure to read to the end before taking any actions :-)

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

Re: Callable library, Hasse diagram

Postby gawrilow » 24 Apr 2013, 23:40

By the way, your code is not economical: you first create a new SimplicialComplex, but in the next line kill it and replace with another object loaded from the file. A default constructor for p or still better a direct initialization would perfectly do. The load function is directly available as a static method of perl::Object, you don't need to wrap it into CallPolymakeFunction - this is more expensive.

pfetsch
Posts: 4
Joined: 24 Apr 2013, 19:23

Re: Callable library, Hasse diagram

Postby pfetsch » 25 Apr 2013, 11:44

Indeed, I have the same problems as in the other thread: linking with graph.so removes the linker error, but then I get a segmentation fault with a similar backtrace:

#0 0x00007ffff600b57e in Perl_newSV_type () from /usr/lib/libperl.so.5.10
#1 0x00007ffff7b9e9b4 in pm::perl::ArrayHolder::init_me(int) () from /local/pfetsch/programs/polymake/lib/libpolymake.so.2.12
#2 0x00007ffff737f904 in T.1944 () from /local/pfetsch/programs/polymake/lib/polymake/lib/graph.so
#3 0x00007ffff7380016 in __do_global_ctors_aux () from /local/pfetsch/programs/polymake/lib/polymake/lib/graph.so
#4 0x00007ffff72d39f3 in _init () from /local/pfetsch/programs/polymake/lib/polymake/lib/graph.so
#5 0x00007ffff7fc5000 in ?? ()
#6 0x00007ffff7debd65 in call_init (main_map=0x7ffff7ffe128, argc=-145052976, argv=0x7fffffffdc08, env=0x7fffffffdc18) at dl-init.c:70
#7 _dl_init (main_map=0x7ffff7ffe128, argc=-145052976, argv=0x7fffffffdc08, env=0x7fffffffdc18) at dl-init.c:134
#8 0x00007ffff7dddb2a in _dl_start_user () from /lib64/ld-linux-x86-64.so.2
#9 0x0000000000000001 in ?? ()
#10 0x00007fffffffe000 in ?? ()
#11 0x0000000000000000 in ?? ()

P.S. I used Perpetual Beta 20130415 (the patch from the other thread has been applied).

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

Re: Callable library, Hasse diagram

Postby gawrilow » 25 Apr 2013, 15:43

Please try the last approach: not linking against graph.so, but allowing for undefined references per linker option.

pfetsch
Posts: 4
Joined: 24 Apr 2013, 19:23

Re: Callable library, Hasse diagram

Postby pfetsch » 25 Apr 2013, 19:07

O.k. I can link, but then we running I get:

polymake: WARNING: available properties insufficient to compute 'DIM'
ERROR: unexpected undefined value of an input property

Code: Select all

int main(int argc, const char* argv[]) { try { Main pm; pm.set_application("topaz"); perl::Object p("SimplicialComplex"); p.load("test.top"); const int dim = p.give("DIM"); std::cout << dim << std::endl; const graph::HasseDiagram HD = p.give("HASSE_DIAGRAM"); } catch (const std::exception& ex) { std::cerr << "ERROR: " << ex.what() << endl; return 1; } return 0; }
Attachments
test.top
(3.04 KiB) Downloaded 453 times

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

Re: Callable library, Hasse diagram

Postby gawrilow » 25 Apr 2013, 23:02

load() is a static function, it returns a new object:

Code: Select all

perl::Object p = perl::Object::load("filename");
For some mysterious reason, its description is missing on the reference Wiki page. I'll edit it right now.

pfetsch
Posts: 4
Joined: 24 Apr 2013, 19:23

Re: Callable library, Hasse diagram

Postby pfetsch » 26 Apr 2013, 13:30

O.k. this fixes my small test program. Unfortunately, copying exactly the same code to my original application results in a segmentation fault:

#0 0x0000000000000000 in ?? ()
#1 0x000000000042799e in pm::perl::Value::operator polymake::graph::HasseDiagram<polymake::graph::HasseDiagram> (this=0x7fffffffd910) at /local/pfetsch/programs/polymake/include/polymake/perl/Value.h:1113
#2 0x0000000000418902 in MORSE_MASTER (this=0x1baa0b0, problem_name=0x1b8a498 "test", file_name=0x7fffffffe013 "test.top", scip=0x1b8a4e0) at src/morse_master.C:128

at

Code: Select all

const graph::HasseDiagram HD = p.give("HASSE_DIAGRAM");

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

Re: Callable library, Hasse diagram

Postby gawrilow » 26 Apr 2013, 15:23

Sorry, but from this tiny snippet of information I can impossibly reconstruct the reason of the crash. If you can't debug it yourself, you can send me your complete program via E-mail, unless it's a top secret or it depends on a long rat tail of third-party software which I would have to install.

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

Re: Callable library, Hasse diagram

Postby gawrilow » 01 May 2013, 21:57

An update on the linker issue: Today (May 1st, 2013) I've submitted a change to the callable library which allows to use the functions and classes from application modules without any linker trickery. Now you just have to add -lpolymake-apps to your linker command; if you are using the utility polymake-config for composing it, the new option will appear automatically.

The cause of your elaborated program crashing is still under investigation.


Return to “Helpdesk”