Application integration without a dynamic library

25 views
Skip to first unread message

Jörg Strebel

unread,
Dec 9, 2021, 3:29:53 PM12/9/21
to Gecode
Hallo!

I would like to use Gecode as a solver for Minesweeper. I am aware of the included example application.Specifically, I would like to extend the KDE /Linux application KMines with Gecode as a minesweeper solver.

The problem is that my Linux distro openSUSE Leap does not include Gecode as a package in the official repos, so I would like to deploy Gecode along with KMines, but without building a deployment package for openSUSE first.

The question is how to do it? I could just include the Gecode source code, I could build Gecode as a static library and deploy that along with KMines or ...?
How do I integrate Gecode into my Linux application without installing it as a shared library in the operating system?

Mikael Zayenz Lagerkvist

unread,
Dec 9, 2021, 3:35:50 PM12/9/21
to Gecode
Hi,

First of all, interesting use case! Hope it works out well.

I'm guessing the easiest way to solve your issue is to make the compilation of Gecode a part of the build process for KMines. There is an option to build static libraries for Gecode, which might be better suited for your particular case.

Also worth noting, is that when compiling Gecode, you can use configure to specify the modules you are interested in compiling. If you are only interested in int variables and search, then you can skip the set variables, the examples, Gist, and so on.

Cheers,
Mikael

Jörg Strebel

unread,
Dec 13, 2021, 1:57:54 AM12/13/21
to Gecode
Hallo! Thanks for the hints!

I configured Gecode using

./configure --enable-static --disable-shared --disable-examples --disable-flatzinc --disable-gist --disable-qt --disable-float-vars --disable-thread --disable-doc-dot --disable-profile --disable-debug -disable-doc-tagfile

I have to use --disable-thread , because I think that my static library cannot reference the shared pthreads library. But when I try to run "make", I get an error message with the first  cpp file:

g++ -I. -fcx-limited-range -fno-signaling-nans -fno-rounding-math -ffinite-math-only -fno-math-errno -fno-strict-aliasing -O3 -fvisibility=hidden -ggdb -std=c++11 -pipe -Wall -Wextra -fPIC -DNDEBUG   \
-c -o gecode/support/exception.o  gecode/support/exception.cpp
In file included from ./gecode/support.hh:102:0,
                from gecode/support/exception.cpp:34:
./gecode/support/thread.hpp:114:2: error: #error No suitable mutex implementation found
#error No suitable mutex implementation found

I had a look at the code - it cannot see where the support/thread/none.hpp is used anywhere. It seems I cannot build  static libraries then.

Jörg Strebel

unread,
Dec 13, 2021, 1:58:01 AM12/13/21
to Gecode
Ok, thank you! I had the same ideas, so this is a good confirmation.

Mikael Zayenz Lagerkvist

unread,
Dec 13, 2021, 2:08:13 AM12/13/21
to Gecode
Interesting, that seems to be an error in compilation without threads (verified on the realease/6.3.0 branch as well for me). I don't think that is a well-tested configuration to be honest, so I'm not fully surprised.

The code in thread.hpp does indeed error out when there is no threading available, so will have to check if it is possible to use no threads.

I've written an issue, and hope to have some time to look into it: https://github.com/Gecode/gecode/issues/136

Cheers,
Mikael

Mikael Zayenz Lagerkvist

unread,
Dec 13, 2021, 2:30:44 AM12/13/21
to Gecode
And as a follow up, I've created a PR for the release/6.3.0 branch to fix this: https://github.com/Gecode/gecode/pull/138 The changes are just to make it compile, I haven't tested yet that it actually does work (will do later)

You can update your code to use that branch for now to test.

Cheers,
Mikael

Jörg Strebel

unread,
Dec 13, 2021, 2:56:55 PM12/13/21
to gec...@googlegroups.com

Hallo!

Thanks for your effort! I managed to build my application nonetheless. I was wrongly assuming that a static library cannot have dependencies on a shared library (pthread in this case) - yes it can, if you link it to one.

The trick is to build Gecode as static libraries with thread support and then compile my own application with the static  libraries and link it with the missing dynamic pthread library. That's ok - the pthread shared library is widely available.

Here is a snippet from my makefile:

CPPFLAGS= -I./gecode -L./gecode

export CPPFLAGS
export CXXFLAGS = $(CPPFLAGS) -fcx-limited-range -fno-signaling-nans -fno-rounding-math -ffinite-math-only -fno-math-errno -fno-strict-aliasing -O2 -fvisibility=hidden -ggdb -std=c++11 -Wall -Wextra $(CXXUSR)
export CFLAGS = $(CPPFLAGS) $(CXXFLAGS) $(CUSR)
export LDLIBS = -lgecodesearch -lgecodeint -lgecodekernel -lgecodesupport -lgecodedriver -lgecodeminimodel -pthread

Regards

Jörg


Am 13.12.21 um 08:30 schrieb Mikael Zayenz Lagerkvist:
--
You received this message because you are subscribed to a topic in the Google Groups "Gecode" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gecode/UzjhYx0msYw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gecode+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gecode/83cb9d7f-04c0-454a-93b5-35908fcdb981n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages