Singular
http://www.singular.uni-kl.de/forum/

coding C++ and calling singular routines
http://www.singular.uni-kl.de/forum/viewtopic.php?f=10&t=2587
Page 1 of 1

Author:  machielk [ Wed Mar 15, 2017 6:35 pm ]
Post subject:  coding C++ and calling singular routines

Can I write a C++ code, and then link to some kind of Singular library so I can call Singular functions to solve my sets of polynomials from within my C++ code? Is there some manual somewhere to explain me how to do it?
If not, is there any other "system of polynomials solving" software that I can do this? I am currently looking into PHCpack which seems to be offer this possibility, but it's not straightforward. Are there any others? Bertini? Hompack? Macaulay2?

Cheers,

Machiel

Author:  hannes [ Thu Mar 16, 2017 6:18 pm ]
Post subject:  Re: coding C++ and calling singular routines

Examples of using libSingular can be found at:
https://github.com/Singular/Sources/blo ... g-test1.cc
https://github.com/Singular/Sources/blo ... g-test2.cc
The comment at the beginning are for version 3.x.x,
for version 4.x.x use the output of libsingular-config
(resp. pkg-config).
To find the functions to call see
https://www.singular.uni-kl.de/dox/html/
(doxygen output from the sources)
and
http://www.mathematik.uni-kl.de/ftp/pub ... natomy.tgz

Author:  machielk [ Mon Mar 20, 2017 5:43 pm ]
Post subject:  Re: coding C++ and calling singular routines

Hi,

Thanks for your reply.
I tried doing what you suggested.
I.e., I downloaded the source code for Singular from https://github.com/Singular/Sources
Then I compiled, using:
Quote:
source autogen.sh
./configure
make

Next, in my a subroutine, "mywork", where I copied the file
Quote:
"https://github.com/Singular/Sources/blob/master/libsing-test1.cc"


To compile this, I had to link to numerous include and lib directories, like this:
Quote:
g++ -I../Singular/ -I../ -I../libpolys/ -I../factory/include/ -o libsing_test1 libsing-test1.cc -L../Singular/.libs/ -lSingular


However, this gives me the error:

Quote:
/usr/bin/ld: /tmp/ccWfd0mN.o: undefined reference to symbol '_Z6p_ISetlP8ip_sring'
//home/mkolstein/Singular/Sources-spielwiese/libpolys/polys/.libs/libpolys-4.0.3.so: error adding symbols: DSO missing from command line

Do you have any suggestions, how to fix this?

Author:  machielk [ Mon Mar 20, 2017 6:45 pm ]
Post subject:  Re: coding C++ and calling singular routines

To answer my own question, to compile, I needed the following command:
Quote:
g++ -I../Singular/ -I../ -I../libpolys/ -I../factory/include/ -o libsing_test1 libsing-test1.cc -L../Singular/.libs/ -lSingular -L../libpolys/polys/.libs/ -lpolys -L../resources/.libs/ -lsingular_resources -L../omalloc/.libs/ -lomalloc


Later, to run the executable "libsing_test1", I needed to set the following environments:
Quote:
export SINGULAR_BASE=/home/mkolstein/Singular/Sources-spielwiese/
export SINGULAR_LIB_DIR=$SINGULAR_BASE/Singular/.libs/
export SINGULAR_LIB_2=$SINGULAR_BASE/libpolys/polys/.libs/
export SINGULAR_LIB_3=$SINGULAR_BASE/resources/.libs/
export SINGULAR_LIB_4=$SINGULAR_BASE/omalloc/.libs/

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$SINGULAR_LIB_DIR:$SINGULAR_LIB_2:$SINGULAR_LIB_3:$SINGULAR_LIB_4

Page 1 of 1 All times are UTC + 1 hour [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/