cbalint13 / gdal-segment

GDAL Segment
GNU General Public License v2.0
65 stars 33 forks source link

Can't compile #3

Open woodbri opened 7 years ago

woodbri commented 7 years ago

Using:

$ g++ --version
g++ (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Setting build type to 'Release' as none was specified.
-- Try OpenMP C flag = [-fopenmp]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Success
-- Try OpenMP CXX flag = [-fopenmp]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Success
-- Found OpenMP: -fopenmp
-- OpenMP found.
-- Found OpenCV: /usr/local (found version "3.2.0") found components:  core ximgproc
-- OpenCV version: 3.2.0
-- OpenCV include: /usr/local/include/usr/local/include/opencv
-- Found GDAL: /usr/lib/libgdal.so
-- GDAL found.
-- GDAL version: 2.2.0
-- Configuring done
-- Generating done
-- Build files have been written to: /u/src/gdal-segment/build
Scanning dependencies of target gdal-segment
[ 25%] Building CXX object src/CMakeFiles/gdal-segment.dir/io/raster.cpp.o
In file included from /usr/include/gdal/gdal.h:42:0,
                 from /u/src/gdal-segment/src/io/raster.cpp:21:
/usr/include/gdal/cpl_port.h:1073:38: error: defaulted and deleted functions only available with -std=c++11 or -std=gnu++11 [-Werror]
     ClassName( const ClassName & ) = delete; \
                                      ^
/usr/include/gdal/gdal_priv.h:113:5: note: in expansion of macro 'CPL_DISALLOW_COPY_ASSIGN'
     CPL_DISALLOW_COPY_ASSIGN(GDALMultiDomainMetadata)
     ^
woodbri commented 7 years ago

I changed the cmake command to cmake -DCMAKE_CXX_FLAGS=-std=c++11 ../ which solved the above issue, but then failed with:

Step 7/9 : RUN cd /u/src/gdal-segment &&        mkdir build && cd build &&        cmake -DCMAKE_CXX_FLAGS=-std=c++11 ../ &&        make &&        cp bin/gdal-segment /usr/local/bin/
 ---> Running in faf4a4b88944
-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Setting build type to 'Release' as none was specified.
-- Try OpenMP C flag = [-fopenmp]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Failed
-- Try OpenMP C flag = [ ]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Failed
-- Try OpenMP C flag = [-fopenmp=libomp]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Failed
-- Try OpenMP C flag = [/openmp]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Failed
-- Try OpenMP C flag = [-Qopenmp]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Failed
-- Try OpenMP C flag = [-openmp]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Failed
-- Try OpenMP C flag = [-xopenmp]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Failed
-- Try OpenMP C flag = [+Oopenmp]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Failed
-- Try OpenMP C flag = [-qsmp]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Failed
-- Try OpenMP C flag = [-mp]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Failed
-- Try OpenMP CXX flag = [-fopenmp]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Success
-- Could NOT find OpenMP (missing:  OpenMP_C_FLAGS)
-- Found OpenCV: /usr/local (found version "3.2.0") found components:  core ximgproc
-- OpenCV version: 3.2.0
-- OpenCV include: /usr/local/include/usr/local/include/opencv
-- Found GDAL: /usr/lib/libgdal.so
-- GDAL found.
-- GDAL version: 2.2.0
-- Configuring done
-- Generating done
-- Build files have been written to: /u/src/gdal-segment/build
Scanning dependencies of target gdal-segment
[ 25%] Building CXX object src/CMakeFiles/gdal-segment.dir/io/raster.cpp.o
/u/src/gdal-segment/src/io/raster.cpp:274:0: error: ignoring #pragma omp parallel [-Werror=unknown-pragmas]
       #pragma omp parallel for schedule(dynamic)
 ^
/u/src/gdal-segment/src/io/raster.cpp:321:0: error: ignoring #pragma omp parallel [-Werror=unknown-pragmas]
       #pragma omp parallel for schedule(dynamic)
 ^
/u/src/gdal-segment/src/io/raster.cpp:335:0: error: ignoring #pragma omp parallel [-Werror=unknown-pragmas]
       #pragma omp parallel for schedule(dynamic)
 ^
/u/src/gdal-segment/src/io/raster.cpp:387:0: error: ignoring #pragma omp parallel [-Werror=unknown-pragmas]
       #pragma omp parallel for schedule(dynamic)
 ^
cc1plus: all warnings being treated as errors
make[2]: *** [src/CMakeFiles/gdal-segment.dir/io/raster.cpp.o] Error 1
src/CMakeFiles/gdal-segment.dir/build.make:62: recipe for target 'src/CMakeFiles/gdal-segment.dir/io/raster.cpp.o' failed
CMakeFiles/Makefile2:85: recipe for target 'src/CMakeFiles/gdal-segment.dir/all' failed
make[1]: *** [src/CMakeFiles/gdal-segment.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
The command '/bin/sh -c cd /u/src/gdal-segment &&        mkdir build && cd build &&        cmake -DCMAKE_CXX_FLAGS=-std=c++11 ../ &&        make &&        cp bin/gdal-segment /usr/local/bin/' returned a non-zero code: 2

FYI, I'm building this in a docker container, on Ubuntu 16.04 using a Dockerfile like:

FROM ubuntu:16.04

RUN apt-get -qqy update &&\
        apt-get -qqy install software-properties-common &&\
        apt-get -qqy update &&\
        add-apt-repository ppa:ubuntugis/ubuntugis-experimental &&\
        apt-get -qqy update &&\
        apt-get -qqy install \
          gdal-bin gdal-data libgdal-dev \
          imagemagick \
          libterm-readline-perl-perl \
          locales-all \
          python-setuptools \
          python-pkg-resources \
          python-gdal \
          python-matplotlib \
          python-matplotlib-data \
          python-scipy \
          python-sciscipy \
          python-scitools \
          python-simplejson \
          python-skimage \
          python-sklearn \
          python-psycopg2 \
          python-numpy \
          sudo \
          vim \
          git \
          cmake cmake-data \
          gcc g++ \
          wget

COPY opencv /u/src/opencv/
COPY gdal-segment /u/src/gdal-segment/

RUN cd /u/src/opencv/ &&\
        mkdir build && cd build &&\
        cmake CMAKE_VERBOSE=1 -DOPENCV_EXTRA_MODULES_PATH=../opencv_contrib/modu
les -DCMAKE_SKIP_RPATH=ON ../ &&\
        make &&\
        make install

RUN cd /u/src/gdal-segment &&\
        mkdir build && cd build &&\
        cmake -DCMAKE_CXX_FLAGS="-std=c++11 -fopenmp" ../ &&\
        make &&\
        cp ../bin/gdal-segment /usr/local/bin/

ENTRYPOINT
CMD ["/bin/bash"]
woodbri commented 7 years ago

OK, looks like I resolved this by changing the cmake line to:

cmake -DCMAKE_CXX_FLAGS="-std=c++11 -fopenmp" ../ &&\

Updated the Docker file above to reflect the changes.

cbalint13 commented 6 years ago

@woodbri ,

Enforced c++1 in CMake requirement. Not sure why your cmake detection dropped out -fopenmp flag (should not happen, perhaps old cmake ? ).

Thank your for interest in this little software !