DGtal-team / DGtal

Digital Geometry Tools and Algorithm Library
https://dgtal.org
GNU Lesser General Public License v3.0
370 stars 115 forks source link

Compilation error in Ubuntu 18.04 #1461

Closed jake-emerson closed 4 years ago

jake-emerson commented 4 years ago

Hi all, I'm having some trouble compiling DGtal. I built GraphicsMagick and libQGLViewer from sources. When running the following I don't get any errors:

cmake .. -DWITH_GMP=true -DWITH_ITK=true -DWITH_CAIRO=true -DWITH_QGLVIEWER=true -DWITH_MAGICK=true

However, if I have sudo apt install qt5-default then I can't install libQGLViewer (it requires Qt4).

With Qt4 I am getting the following error:

box:~/DGtal/build$ make
[  0%] Building CXX object src/CMakeFiles/DGtal.dir/DGtal/kernel/NumberTraits.cpp.o
In file included from /usr/local/include/QGLViewer/vec.h:32:0,
                 from /usr/local/include/QGLViewer/quaternion.h:26,
                 from /usr/local/include/QGLViewer/keyFrameInterpolator.h:29,
                 from /usr/local/include/QGLViewer/camera.h:27,
                 from /usr/local/include/QGLViewer/qglviewer.h:26,
                 from /home/jake/DGtal/src/DGtal/base/Common.h:46,
                 from /home/jake/DGtal/src/DGtal/kernel/NumberTraits.h:48,
                 from /home/jake/DGtal/src/DGtal/kernel/NumberTraits.cpp:30:
/usr/local/include/QGLViewer/config.h:43:34: error: too many decimal points in number
         : Use a version prior to 2.7.0 to remove this constraint
                                  ^~~~~
/usr/local/include/QGLViewer/config.h:80:10: fatal error: QOpenGLWidget: No such file or directory
 #include <QOpenGLWidget>
          ^~~~~~~~~~~~~~~
compilation terminated.
src/CMakeFiles/DGtal.dir/build.make:62: recipe for target 'src/CMakeFiles/DGtal.dir/DGtal/kernel/NumberTraits.cpp.o' failed
make[2]: *** [src/CMakeFiles/DGtal.dir/DGtal/kernel/NumberTraits.cpp.o] Error 1
CMakeFiles/Makefile2:693: recipe for target 'src/CMakeFiles/DGtal.dir/all' failed
make[1]: *** [src/CMakeFiles/DGtal.dir/all] Error 2
Makefile:151: recipe for target 'all' failed
make: *** [all] Error 2

Is there some way out of this circular dependency problem? Is there a Dockerfile out there somewhere that will work to show a full installation example?

dcoeurjo commented 4 years ago

Thanks for the issue report. On my ubuntu18.04, I wasn't able to reproduce your issue. There may be a problem with your qglviewer version, how did you install it ?

On 18.04, the package version is 2.6.3 (working with qt4 and qt5). With that default package version, everything works fine (both qt5 and qt4) when building DGtal.

Can you please confirm me?

copyme commented 4 years ago

@jake-emerson Cannot test on 18.04 but back in the day you needed:

libqglviewer-dev-qt4, libqglviewer-headers, libqglviewer2-qt4

jake-emerson commented 4 years ago

Moving to version 2.6.3 of QGLViewer fixed my original error. I stuck with qt5. Thank you!

Now I have an issue with linking GraphicsMagick. I tested my install with the following:

> GraphicsMagick++-config --ldflags --libs
-L/usr/local/lib 
-lGraphicsMagick++ -lGraphicsMagick -ljbig -lwebp -lwebpmux -llcms2 -ltiff -lfreetype -ljpeg -lpng16 -lwmflite -lXext -lSM -lICE -lX11 -llzma -lbz2 -lxml2 -lz -lm -lpthread -lgomp

which seems to be fine. However, when I cmake DGtal it is unable to link properly.

I use the following for cmake:

> cmake .. -DWITH_GMP=true -DWITH_ITK=true -DWITH_EIGEN=true -DWITH_CAIRO=true -DWITH_QGLVIEWER=true -DWITH_MAGICK=true -DWITH_QT5=true -DCMAKE_BUILD_TYPE=debug -DVERBOSE=true -DDEBUG_VERBOSE=true /home/jake/DGtal

and make produces the following (truncated) error:

[  6%] Linking CXX executable imageBasicSubsampling                                                                                                                                           
/usr/local/lib/libGraphicsMagick++.a(Magick___lib_libGraphicsMagick___la-Geometry.o): In function `Magick::Geometry::operator=(std::__cxx11::basic_string<char, std::char_traits<char>, std::$
llocator<char> > const&)':                                                                                                                                                                    
Geometry.cpp:(.text+0xcf3): undefined reference to `MagickStrlCpy'
Geometry.cpp:(.text+0xd3d): undefined reference to `GetPageGeometry'
Geometry.cpp:(.text+0xd6c): undefined reference to `MagickStrlCpy'
Geometry.cpp:(.text+0xd89): undefined reference to `MagickFree'
Geometry.cpp:(.text+0xdee): undefined reference to `GetGeometry'
/usr/local/lib/libGraphicsMagick++.a(Magick___lib_libGraphicsMagick___la-Geometry.o): In function `Magick::Geometry::operator std::__cxx11::basic_string<char, std::char_traits<char>, std::al
locator<char> >() const':
Geometry.cpp:(.text+0x11bd): undefined reference to `FormatString'
Geometry.cpp:(.text+0x1216): undefined reference to `FormatString'
Geometry.cpp:(.text+0x12c5): undefined reference to `FormatString'
Geometry.cpp:(.text+0x1340): undefined reference to `FormatString'
/usr/local/lib/libGraphicsMagick++.a(Magick___lib_libGraphicsMagick___la-Image.o): In function `Magick::Image::adaptiveThreshold(unsigned int, unsigned int, double)':
Image.cpp:(.text+0xd80): undefined reference to `GetExceptionInfo'
Image.cpp:(.text+0xdbe): undefined reference to `AdaptiveThresholdImage'

...

/usr/local/lib/libGraphicsMagick++.a(Magick___lib_libGraphicsMagick___la-Functions.o): In function `Magick::CloneString(char**, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
Functions.cpp:(.text+0x2a): undefined reference to `CloneString'
collect2: error: ld returned 1 exit status
examples/images/CMakeFiles/imageBasicSubsampling.dir/build.make:222: recipe for target 'examples/images/imageBasicSubsampling' failed
make[2]: *** [examples/images/imageBasicSubsampling] Error 1
CMakeFiles/Makefile2:815: recipe for target 'examples/images/CMakeFiles/imageBasicSubsampling.dir/all' failed
make[1]: *** [examples/images/CMakeFiles/imageBasicSubsampling.dir/all] Error 2
Makefile:151: recipe for target 'all' failed
make: *** [all] Error 2

I compiled GraphicsMagick as follows:

wget https://sourceforge.net/projects/graphicsmagick/files/graphicsmagick/1.3.31/GraphicsMagick-1.3.31.tar.gz
tar -xzf GraphicsMagick-1.3.31.tar.gz
cd GraphicsMagick-1.3.31
./configure
make
make install
ldconfig /usr/local/lib
jake-emerson commented 4 years ago

Based on this PR I'm wondering if I should just switch to ImageMagick. https://github.com/DGtal-team/DGtal/pull/1366

jake-emerson commented 4 years ago

Scratch that. The FindMagick.cmake script seems to only look for GraphicsMagick: https://github.com/DGtal-team/DGtal/blob/1.0/cmake/FindMagick.cmake

copyme commented 4 years ago

@jake-emerson it works here (openSUSE 15.1) with GraphicsMagick 1.3.34

copyme commented 4 years ago

@jake-emerson I suggest compiling GraphicsMagick with --enable-shared --disable-static

copyme commented 4 years ago

@jake-emerson here you can see other compilation flags used by openSUSE package system. See lines starting from %configure.

dcoeurjo commented 4 years ago

Can this PR be closed?