Gecode / gecode

Generic Constraint Development Environment
https://www.gecode.org
Other
275 stars 76 forks source link

Fails to build with ENABLE_GIST=ON: undefined reference to vtable for Gecode::Gist::GistMainWindow #96

Closed yurivict closed 3 years ago

yurivict commented 3 years ago
[241/241] : && /usr/bin/c++ -O2 -pipe -fno-omit-frame-pointer -fstack-protector-strong -fno-strict-aliasing -fno-omit-frame-pointer -std=c++11 -O2 -pipe -fno-omit-frame-pointer -fstack-protector-strong -fno-strict-aliasing -fno-omit-frame-pointer -fstack-protector-strong CMakeFiles/fzn-gecode.dir/fzn-gecode_autogen/mocs_compilation.cpp.o CMakeFiles/fzn-gecode.dir/tools/flatzinc/fzn-gecode.cpp.o -o bin/fzn-gecode  -Wl,-rpath,/usr/ports/devel/gecode/work/.build:/usr/local/lib/qt5:/usr/local/lib:  libgecodeflatzinc.so  libgecodeminimodel.so  libgecodedriver.so  libgecodeset.so  libgecodesearch.so  libgecodefloat.so  libgecodeint.so  libgecodekernel.so  libgecodesupport.so  -pthread  libgecodegist.so  /usr/local/lib/qt5/libQt5PrintSupport.so.5.15.0  /usr/local/lib/qt5/libQt5Widgets.so.5.15.0  /usr/local/lib/qt5/libQt5Gui.so.5.15.0  /usr/local/lib/qt5/libQt5Core.so.5.15.0  -Wl,-rpath-link,/usr/local/lib && :
FAILED: bin/fzn-gecode 
: && /usr/bin/c++ -O2 -pipe -fno-omit-frame-pointer -fstack-protector-strong -fno-strict-aliasing -fno-omit-frame-pointer -std=c++11 -O2 -pipe -fno-omit-frame-pointer -fstack-protector-strong -fno-strict-aliasing -fno-omit-frame-pointer -fstack-protector-strong CMakeFiles/fzn-gecode.dir/fzn-gecode_autogen/mocs_compilation.cpp.o CMakeFiles/fzn-gecode.dir/tools/flatzinc/fzn-gecode.cpp.o -o bin/fzn-gecode  -Wl,-rpath,/usr/ports/devel/gecode/work/.build:/usr/local/lib/qt5:/usr/local/lib:  libgecodeflatzinc.so  libgecodeminimodel.so  libgecodedriver.so  libgecodeset.so  libgecodesearch.so  libgecodefloat.so  libgecodeint.so  libgecodekernel.so  libgecodesupport.so  -pthread  libgecodegist.so  /usr/local/lib/qt5/libQt5PrintSupport.so.5.15.0  /usr/local/lib/qt5/libQt5Widgets.so.5.15.0  /usr/local/lib/qt5/libQt5Gui.so.5.15.0  /usr/local/lib/qt5/libQt5Core.so.5.15.0  -Wl,-rpath-link,/usr/local/lib && :
ld: error: libgecodegist.so: undefined reference to vtable for Gecode::Gist::GistMainWindow
ld: error: libgecodegist.so: undefined reference to vtable for Gecode::Gist::TextOutputI
ld: error: libgecodegist.so: undefined reference to Gecode::Gist::TreeCanvas::contextMenu(QContextMenuEvent*)
ld: error: libgecodegist.so: undefined reference to Gecode::Gist::TreeCanvas::scaleChanged(int)
ld: error: libgecodegist.so: undefined reference to Gecode::Gist::TreeCanvas::addedBookmark(QString const&)
ld: error: libgecodegist.so: undefined reference to Gecode::Gist::TreeCanvas::statusChanged(Gecode::Gist::VisualNode*, Gecode::Gist::Statistics const&, bool)
ld: error: libgecodegist.so: undefined reference to Gecode::Gist::TreeCanvas::autoZoomChanged(bool)
ld: error: libgecodegist.so: undefined reference to Gecode::Gist::TreeCanvas::removedBookmark(int)
ld: error: libgecodegist.so: undefined reference to Gecode::Gist::TreeCanvas::staticMetaObject
ld: error: libgecodegist.so: undefined reference to Gecode::Gist::TreeCanvas::solution(Gecode::Space const*)
ld: error: libgecodegist.so: undefined reference to Gecode::Gist::SearcherThread::moveToNode(Gecode::Gist::VisualNode*, bool)
ld: error: libgecodegist.so: undefined reference to Gecode::Gist::SearcherThread::statusChanged(bool)
ld: error: libgecodegist.so: undefined reference to Gecode::Gist::SearcherThread::searchFinished()
ld: error: libgecodegist.so: undefined reference to Gecode::Gist::SearcherThread::update(int, int, int)
ld: error: libgecodegist.so: undefined reference to Gecode::Gist::SearcherThread::solution(Gecode::Space const*)
ld: error: libgecodegist.so: undefined reference to vtable for Gecode::Gist::TreeCanvas
ld: error: libgecodegist.so: undefined reference to vtable for Gecode::Gist::SearcherThread
ld: error: libgecodegist.so: undefined reference to Gecode::Gist::Gist::statusChanged(Gecode::Gist::Statistics const&, bool)
ld: error: libgecodegist.so: undefined reference to vtable for Gecode::Gist::Gist
ld: error: libgecodegist.so: undefined reference to vtable for Gecode::Gist::NodeStatInspector
ld: error: too many errors emitted, stopping now (use -error-limit=0 to see all errors)
c++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

clang-10 FreeBSD 12.2

zayenz commented 3 years ago

For the record, how did you compile Gecode and what vesion of Qt do you have installed?

With that said, we do not typically test on FreeBSD, nor do we actually have any FreeBSD machines, so we might not be able to help.

If anyone else has any idea what the problem is, please don't hesitate to chime in.

yurivict commented 3 years ago

I compiled the FreeBSD port devel/gecode with the option GIST=ON. qt-5.15.0 cmake-3.18.3 clang-10

yurivict commented 3 years ago

Here is the build log: https://people.freebsd.org/~yuri/gecode-6.2.0-build-failure.log

Some object modules, particularly treecanvas.cpp.o, don't get linked into the library libgecodegist.so, which is an immediate cause of this problem.

Do you know why might it not get added to this library?

Version 6.2.0.

zayenz commented 3 years ago

Unfortunately I don't have much insight here at this moment, I've not tried to build with Qt for a long time, and never with the CMake build system.

@guidotack Do you have any idea what might be wrong here?

yurivict commented 3 years ago

and never with the CMake build system.

Then the problem is likely that cmake scripts don't add gist sources to the library when the option is selected.

Dekker1 commented 3 years ago

I use the following script to build Gecode using CMake with gist for Windows, Mac, and 2 Linux distributions without any issues:

# Usage: gecode.sh {build_with_gist:0/1}
set -e
set -x

DIR="gecode"
if [ $1 = 1 ]; then
    ENABLE_GIST=TRUE
    if [ ! -x "$(command -v qmake)" ]; then
          echo "!!!!!!!!!!!!!! CANNOT FIND QMAKE !!!!!!!!!!!!"
          exit 1
    fi
    DIR="gecode_gist"
else
    ENABLE_GIST=FALSE
fi

mkdir -p {build,vendor}/$DIR
cd build/$DIR

cmake -G"$CMAKEARCH" $CI_PROJECT_DIR/gecode -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$CI_PROJECT_DIR/vendor/$DIR -DENABLE_GIST=${ENABLE_GIST} -DENABLE_CPPROFILER=TRUE
cmake --build . --config Release
cmake --build . --config Release --target install

My guess would be that either the version of CMake or the version of Qt is interfering with the build.

yurivict commented 3 years ago

I build about the same way.

cmake-3.18.3 qt5-qmake-5.15.0

yurivict commented 3 years ago

https://github.com/Gecode/gecode/pull/102