[GRASS-dev] [GRASS GIS] #2017: osgf compilation errro

#2017: osgf compilation errro
-----------------------+----------------------------------------------------
Reporter: martinl | Owner: grass-dev@…
     Type: defect | Status: new
Priority: blocker | Milestone: 7.0.0
Component: Compiling | Version: svn-trunk
Keywords: libc | Platform: Linux
      Cpu: x86-64 |
-----------------------+----------------------------------------------------
Hi, recently I discovered problem when compiling `ogsflib`.

{{{
In file included from /usr/include/x86_64-linux-gnu/sys/stat.h:106:0,
                  from /home/martin/src/grass_trunk/dist.x86_64-unknown-
linux-gnu/include/grass/config.h:311,
                  from /home/martin/src/grass_trunk/dist.x86_64-unknown-
linux-gnu/include/grass/gis.h:28,
                  from GK2.c:21:
/usr/include/x86_64-linux-gnu/bits/stat.h:91:21: error: field ‘st_atim’
has incomplete type
/usr/include/x86_64-linux-gnu/bits/stat.h:92:21: error: field ‘st_mtim’
has incomplete type
/usr/include/x86_64-linux-gnu/bits/stat.h:93:21: error: field ‘st_ctim’
has incomplete type
In file included from /home/martin/src/grass_trunk/dist.x86_64-unknown-
linux-gnu/include/grass/config.h:311:0,
                  from /home/martin/src/grass_trunk/dist.x86_64-unknown-
linux-gnu/include/grass/gis.h:28,
                  from GK2.c:21:
/usr/include/x86_64-linux-gnu/sys/stat.h:366:31: error: array type has
incomplete element type
/usr/include/x86_64-linux-gnu/sys/stat.h:373:54: error: array type has
incomplete element type
}}}

Debian GNU/Linux Unstable

{{{
gcc --version
gcc (Debian 4.7.3-5) 4.7.3
}}}

{{{
Package: libc6-dev
Versions:
2.17-7
}}}

{{{
         CFLAGS="-g -Wall -Werror-implicit-function-declaration -fno-common
-Wextra -Wunused" \
             CXXFLAGS="-g -Wall" \
             ./configure --prefix=/home/martin/smetiste/g7 \
             --with-postgres --with-postgres-
includes=/usr/include/postgresql \
             --with-gdal=/usr/local/bin/gdal-config \
             --with-proj --with-cxx --enable-largefile --with-sqlite \
             --with-motif --with-glw --with-nls --with-readline \
             --with-freetype --with-freetype-
includes=/usr/include/freetype2 \
             --with-odbc --with-python=/usr/bin/python-config --with-
wxwidgets \
             --with-ffmpeg \
             --with-ffmpeg-includes="/usr/include/libavcodec
/usr/include/libavformat/ /usr/include/libswscale /usr/include/libavutil/"
\
             --with-geos=/usr/local/bin/geos-config --with-pthread \
             --with-mysql --with-mysql-includes=/usr/include/mysql --with-
cairo \
             --with-liblas --with-readline-libs=/lib/x86_64-linux-gnu
--with-openmp --with-opencl \
             --with-netcdf --with-x --x-includes=/usr/include
--x-libraries=/usr/lib/x86_64-linux-gnu
}}}

Any idea what could be wrong?

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2017&gt;
GRASS GIS <http://grass.osgeo.org>

#2017: osgf compilation error
-----------------------+----------------------------------------------------
Reporter: martinl | Owner: grass-dev@…
     Type: defect | Status: new
Priority: blocker | Milestone: 7.0.0
Component: Compiling | Version: svn-trunk
Keywords: libc | Platform: Linux
      Cpu: x86-64 |
-----------------------+----------------------------------------------------

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2017#comment:1&gt;
GRASS GIS <http://grass.osgeo.org>

#2017: osgf compilation error
-----------------------+----------------------------------------------------
Reporter: martinl | Owner: grass-dev@…
     Type: defect | Status: new
Priority: blocker | Milestone: 7.0.0
Component: Compiling | Version: svn-trunk
Keywords: libc | Platform: Linux
      Cpu: x86-64 |
-----------------------+----------------------------------------------------

Comment(by mmetz):

Replying to [ticket:2017 martinl]:
> Hi, recently I discovered problem when compiling `ogsflib`.
>
{{{
In file included from /usr/include/x86_64-linux-gnu/sys/stat.h:106:0,
                  from /home/martin/src/grass_trunk/dist.x86_64-unknown-
linux-gnu/include/grass/config.h:311,
                   from /home/martin/src/grass_trunk/dist.x86_64-unknown-
linux-gnu/include/grass/gis.h:28,
                   from GK2.c:21:
/usr/include/x86_64-linux-gnu/bits/stat.h:91:21: error: field ‘st_atim’
has incomplete type
/usr/include/x86_64-linux-gnu/bits/stat.h:92:21: error: field ‘st_mtim’
has incomplete type
/usr/include/x86_64-linux-gnu/bits/stat.h:93:21: error: field ‘st_ctim’
has incomplete type
In file included from /home/martin/src/grass_trunk/dist.x86_64-unknown-
linux-gnu/include/grass/config.h:311:0,
                  from /home/martin/src/grass_trunk/dist.x86_64-unknown-
linux-gnu/include/grass/gis.h:28,
                  from GK2.c:21:
/usr/include/x86_64-linux-gnu/sys/stat.h:366:31: error: array type has
incomplete element type
/usr/include/x86_64-linux-gnu/sys/stat.h:373:54: error: array type has
incomplete element type
}}}
>
> Debian GNU/Linux Unstable

> Any idea what could be wrong?

Yes, my recent addition of `#include <sys/stat.h>` to config.h.in. Try to
add `#include <sys/stat.h>` or `#include <unistd.h>` or both as in

{{{
        #include <sys/types.h>
        #include <sys/stat.h>
        #include <unistd.h>
}}}

to config.h.in:311.

Weird that it works on different Linux systems, FreeBSD, Solaris, IBM AIX,
but not on Debian GNU/Linux Unstable. If it works on Debian Stable, I
would recommend to hack your local copy.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2017#comment:2&gt;
GRASS GIS <http://grass.osgeo.org>

#2017: osgf compilation error
-----------------------+----------------------------------------------------
Reporter: martinl | Owner: grass-dev@…
     Type: defect | Status: new
Priority: blocker | Milestone: 7.0.0
Component: Compiling | Version: svn-trunk
Keywords: libc | Platform: Linux
      Cpu: x86-64 |
-----------------------+----------------------------------------------------

Comment(by mlennert):

I cannot reproduce this on Debian GNU/Linux testing.

Moritz

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2017#comment:3&gt;
GRASS GIS <http://grass.osgeo.org>

#2017: osgf compilation error
-----------------------+----------------------------------------------------
Reporter: martinl | Owner: grass-dev@…
     Type: defect | Status: new
Priority: blocker | Milestone: 7.0.0
Component: Compiling | Version: svn-trunk
Keywords: libc | Platform: Linux
      Cpu: x86-64 |
-----------------------+----------------------------------------------------

Comment(by hamish):

Hi,

using today's debian/unstable (gcc 4.8.1-6, libc6-dev 2.17-7) and today's
grass trunk, all builds ok for me, no errors. Martin, perhaps try again?

Hamish

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2017#comment:4&gt;
GRASS GIS <http://grass.osgeo.org>

#2017: osgf compilation error
-----------------------+----------------------------------------------------
Reporter: martinl | Owner: grass-dev@…
     Type: defect | Status: new
Priority: blocker | Milestone: 7.0.0
Component: Compiling | Version: svn-trunk
Keywords: libc | Platform: Linux
      Cpu: x86-64 |
-----------------------+----------------------------------------------------

Comment(by mlennert):

Martin,

Can you confirm this issue, or can we close the bug ?

Moritz

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2017#comment:5&gt;
GRASS GIS <http://grass.osgeo.org>

#2017: osgf compilation error
-----------------------+----------------------------------------------------
Reporter: martinl | Owner: grass-dev@…
     Type: defect | Status: new
Priority: blocker | Milestone: 7.0.0
Component: Compiling | Version: svn-trunk
Keywords: libc | Platform: Linux
      Cpu: x86-64 |
-----------------------+----------------------------------------------------

Comment(by martinl):

Replying to [comment:5 mlennert]:
> Martin,
>
> Can you confirm this issue, or can we close the bug ?

I can still confirm this issue. I have reinstalled `libc6-dev` package
(`libc6-dev:amd64 (2.17-92)`), but it didn't help.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2017#comment:6&gt;
GRASS GIS <http://grass.osgeo.org>

#2017: osgf compilation error
-----------------------+----------------------------------------------------
Reporter: martinl | Owner: grass-dev@…
     Type: defect | Status: new
Priority: blocker | Milestone: 7.0.0
Component: Compiling | Version: svn-trunk
Keywords: libc | Platform: Linux
      Cpu: x86-64 |
-----------------------+----------------------------------------------------

Comment(by mlennert):

Replying to [comment:6 martinl]:
> Replying to [comment:5 mlennert]:
> > Martin,
> >
> > Can you confirm this issue, or can we close the bug ?
>
> I can still confirm this issue. I have reinstalled `libc6-dev` package
(`libc6-dev:amd64 (2.17-92)`), but it didn't help.

Here with gcc (Debian 4.7.3-4) 4.7.3 and the same libc6-dev package on
Debian testing, and your CFLAGS I still cannot reproduce. Maybe you could
try with gcc 4.8 as Hamish did ? Anything in your local copy of the source
?

Moritz

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2017#comment:7&gt;
GRASS GIS <http://grass.osgeo.org>

#2017: osgf compilation error
-----------------------+----------------------------------------------------
Reporter: martinl | Owner: grass-dev@…
     Type: defect | Status: new
Priority: blocker | Milestone: 7.0.0
Component: Compiling | Version: svn-trunk
Keywords: libc | Platform: Linux
      Cpu: x86-64 |
-----------------------+----------------------------------------------------

Comment(by martinl):

OK, the reason is that `/usr/include/libavutil` already contains `time.h`
header file (1). I am using

{{{
--with-ffmpeg-includes="/usr/include/libavcodec /usr/include/libavformat/
/usr/include/libswscale /usr/include/libavutil"
}}}

without `/usr/include/libavutil` I get

{{{
gsd_img_mpeg.c:33:25: fatal error: mathematics.h: No such file or
directory
  #include <mathematics.h>
}}}

(1) http://stackoverflow.com/questions/14947691/c-system-file-bits-stat-h
-suddenly-breaks-with-error-field-st-atim-has-inc

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2017#comment:8&gt;
GRASS GIS <http://grass.osgeo.org>

#2017: osgf compilation error
-----------------------+----------------------------------------------------
Reporter: martinl | Owner: grass-dev@…
     Type: defect | Status: new
Priority: blocker | Milestone: 7.0.0
Component: Compiling | Version: svn-trunk
Keywords: libc | Platform: Linux
      Cpu: x86-64 |
-----------------------+----------------------------------------------------

Comment(by martinl):

Replying to [comment:8 martinl]:
> OK, the reason is that `/usr/include/libavutil` already contains
`time.h` header file (1). I am using

{{{
apt-file search /usr/include/libavutil/time.h
libavutil-dev: /usr/include/libavutil/time.h

...
Package: libavutil-dev
Source: libav
Version: 6:0.8.7-1
}}}

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2017#comment:9&gt;
GRASS GIS <http://grass.osgeo.org>

#2017: osgf compilation error
-----------------------------------+----------------------------------------
Reporter: martinl | Owner: grass-dev@…
     Type: defect | Status: new
Priority: blocker | Milestone: 7.0.0
Component: Compiling | Version: svn-trunk
Keywords: libc, osgf, libavutil | Platform: Linux
      Cpu: x86-64 |
-----------------------------------+----------------------------------------
Changes (by hamish):

  * keywords: libc => libc, osgf, libavutil

Comment:

martinl wrote:
> gsd_img_mpeg.c:33:25: fatal error: mathematics.h: No such file or
directory

lib/ogsf/gsd_img_mpeg.c
{{{
/* FFMPEG stuff */
#ifdef HAVE_FFMPEG
#include <avformat.h>
#include <avio.h>
#if LIBAVUTIL_VERSION_MAJOR < 51
#include <avutil.h>
#else
/* libavutil 51.22.1's avutil.h doesn't include libavutil/mathematics.h */
#include <mathematics.h>
#endif
}}}

> Package: libavutil-dev
> Source: libav
> Version: 6:0.8.7-1

what version of libavutil does that provide?
(look in /usr/include/libavutil/avutil.h for
LIBAVUTIL_VERSION_MAJOR,MINOR,MICRO)

supposedly newer versions of Debian have switched to more stable versions
of these libraries which could put an end to this game of cat and mouse,
but I'm tempted to drop the in-program MPEG creation in favour of creating
a series of frames and outsourcing the encoding entirely to 3rd party
software.

anyway IIRC that code isn't used by anything in trunk right now, so no
benefit of using --with-ffmpeg when building GRASS 7 (currently).

Hamish

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2017#comment:10&gt;
GRASS GIS <http://grass.osgeo.org>

#2017: osgf compilation error
-----------------------------------+----------------------------------------
Reporter: martinl | Owner: grass-dev@…
     Type: defect | Status: new
Priority: blocker | Milestone: 7.0.0
Component: Compiling | Version: svn-trunk
Keywords: libc, osgf, libavutil | Platform: Linux
      Cpu: x86-64 |
-----------------------------------+----------------------------------------

Comment(by martinl):

Replying to [comment:10 hamish]:
> what version of libavutil does that provide?
> (look in /usr/include/libavutil/avutil.h for
LIBAVUTIL_VERSION_MAJOR,MINOR,MICRO)

{{{
version.h:#define LIBAVUTIL_VERSION_MAJOR 52
version.h:#define LIBAVUTIL_VERSION_MINOR 18
version.h:#define LIBAVUTIL_VERSION_MICRO 100
}}}

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2017#comment:11&gt;
GRASS GIS <http://grass.osgeo.org>

#2017: osgf compilation error
-----------------------------------+----------------------------------------
Reporter: martinl | Owner: grass-dev@…
     Type: defect | Status: new
Priority: blocker | Milestone: 7.0.0
Component: Compiling | Version: svn-trunk
Keywords: libc, osgf, libavutil | Platform: Linux
      Cpu: x86-64 |
-----------------------------------+----------------------------------------

Comment(by glynn):

Replying to [comment:8 martinl]:
> OK, the reason is that `/usr/include/libavutil` already contains
`time.h` header file
It appears that they '''really''' don't want anyone else to use their
library.

Just one more reason to abandon FFMPEG support. If we didn't have enough
of those already.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2017#comment:12&gt;
GRASS GIS <http://grass.osgeo.org>

#2017: osgf compilation error (fixed?)
-----------------------------------+----------------------------------------
Reporter: martinl | Owner: grass-dev@…
     Type: defect | Status: new
Priority: blocker | Milestone: 7.0.0
Component: Compiling | Version: svn-trunk
Keywords: libc, osgf, libavutil | Platform: Linux
      Cpu: x86-64 |
-----------------------------------+----------------------------------------

Comment(by edleaver):

My I tactfully disagree? If one needs libffmpeg functions, by all means
use them. Just lets not get carried away with compiler include directives.
I've reproduced the particular problem as originally reported by martini
on Fedora fc19 and fc20, where it is readily fixed:

1. remove /usr/include/libavutil/ from --with-ffmpeg-includes paths

2. lib/ogsf/gsd_img_mpeg.c line 33 should read
       #include <libavutil/mathematics.h>
    rather than
       #include <mathematics.h>

That should be all that is necessary, for now. As a general point,
however, one
might opine that *all* libffmpeg #includes should be written relative to
the first
--with-ffmpeg-includes="/usr/include"
directory, or on Fedora
--with-ffmpeg-includes="/usr/include/ffmpeg"
as shown above, though as a practical matter the "configure" script fails
if it
can't find at least some of the ffmpeg subdirectories and I wouldn't
insist we fix such a thing that isn't otherwise broken.

Think of the "top-level only" paradigm as being a method for maintaining
separate
namespaces for different development libraries. If in our Makefiles we
"-I<everything under the sun>", then <everything under the sun> must have
a unique file name, rather than just a unique relative path. Given enough
libraries with
enough separate headers, sooner or later we're going to have name
collisions. We
happened to hit one with libffmpeg. But if such is our philosophy, if not
here it was going to happen another time, somewhere else.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2017#comment:13&gt;
GRASS GIS <http://grass.osgeo.org>

#2017: osgf compilation error (fixed?)
-----------------------------------+----------------------------------------
Reporter: martinl | Owner: grass-dev@…
     Type: defect | Status: new
Priority: critical | Milestone: 7.0.0
Component: Compiling | Version: svn-trunk
Keywords: libc, osgf, libavutil | Platform: Linux
      Cpu: x86-64 |
-----------------------------------+----------------------------------------
Changes (by martinl):

  * priority: blocker => critical

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2017#comment:14&gt;
GRASS GIS <http://grass.osgeo.org>

#2017: osgf compilation error (fixed?)
-----------------------------------+----------------------------------------
Reporter: martinl | Owner: grass-dev@…
     Type: defect | Status: new
Priority: critical | Milestone: 7.0.0
Component: Compiling | Version: svn-trunk
Keywords: libc, osgf, libavutil | Platform: Linux
      Cpu: x86-64 |
-----------------------------------+----------------------------------------

Comment(by hamish):

if we're not using it in trunk, and AFAIK we aren't since tcl/tk nviz went
away, my vote is to just drop the dependency & outsource the problem to
mencoder et al.

On the other hand, if you'd like me to fix it I can continue with the
information provided in comment:11.

regards,
Hamish

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2017#comment:15&gt;
GRASS GIS <http://grass.osgeo.org>

#2017: osgf compilation error (fixed?)
-----------------------------------+----------------------------------------
Reporter: martinl | Owner: grass-dev@…
     Type: defect | Status: new
Priority: critical | Milestone: 7.0.0
Component: Compiling | Version: svn-trunk
Keywords: libc, osgf, libavutil | Platform: Linux
      Cpu: x86-64 |
-----------------------------------+----------------------------------------

Comment(by edleaver):

Replying to [comment:15 hamish]:
Well, I'm not a GRASS dev, but fwiw while the #include
<libavutil/mathematics.h> fix to gsd_img_mpeg.c enabled a successful build
back in January, more recently I've run into problems with ctypes
generation / python wrapping when FFMPEG was enabled, e.g. at svn revision
59324:

python -t -3 -m py_compile
/home/leaver/project/Grass/Fedora/grass7_svn/dist.x86_64-unknown-linux-
gnu/etc/python/grass/lib/vedit.py[[BR]]
Status: Processing description list.[[BR]]
Error: /usr/include/GL/gl.h:90: Syntax error at '\n'[[BR]]
Error: /usr/include/GL/gl.h:93: Syntax error at '\n'[[BR]]
Status: Processing description list.

...and stops (with 4% cpu usage in python process). I haven't traced the
source, but this doesn't occur when I remove --with-ffmpeg and friends
from my configuration script, and grass7_svn then successfully builds. I'm
not reporting this as a bug, only as an fyi that there may exist ffmpeg
issues beyond the include paths, should you choose to pursue them.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2017#comment:16&gt;
GRASS GIS <http://grass.osgeo.org>

#2017: osgf compilation error
-------------------------------------------+--------------------------------
Reporter: martinl | Owner: grass-dev@…
     Type: defect | Status: new
Priority: critical | Milestone: 7.0.0
Component: Compiling | Version: svn-trunk
Keywords: libc, osgf, libavutil, ffmpeg | Platform: Linux
      Cpu: x86-64 |
-------------------------------------------+--------------------------------
Changes (by wenzeslaus):

  * keywords: libc, osgf, libavutil => libc, osgf, libavutil, ffmpeg

Comment:

So, current state is that GRASS has to be compiled without `ffmpeg`
(`avutil`):
{{{
--with-ffmpeg=no
}}}
This probably applies to all GRASS branches and most of the platforms.

''Removing status from the ticket title. Please keep discussion about
ticket status in ticket comments.''

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2017#comment:17&gt;
GRASS GIS <http://grass.osgeo.org>

#2017: ogsf compilation error
-------------------------------------------+--------------------------------
Reporter: martinl | Owner: grass-dev@…
     Type: defect | Status: new
Priority: critical | Milestone: 7.0.0
Component: Compiling | Version: svn-trunk
Keywords: libc, ogsf, libavutil, ffmpeg | Platform: Linux
      Cpu: x86-64 |
-------------------------------------------+--------------------------------
Changes (by glynn):

  * keywords: libc, osgf, libavutil, ffmpeg => libc, ogsf, libavutil,
               ffmpeg

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2017#comment:18&gt;
GRASS GIS <http://grass.osgeo.org>

#2017: ogsf compilation error
-------------------------------------------+--------------------------------
Reporter: martinl | Owner: grass-dev@…
     Type: defect | Status: new
Priority: critical | Milestone: 7.0.0
Component: Compiling | Version: svn-trunk
Keywords: libc, ogsf, libavutil, ffmpeg | Platform: Linux
      Cpu: x86-64 |
-------------------------------------------+--------------------------------

Comment(by wenzeslaus):

See also [http://lists.osgeo.org/pipermail/grass-dev/2014-June/069702.html
GRASS-dev G7: OGSF compilation error on Ubuntu 14.04] for some more error
messages.

According to the ticket, this applies to Debian and Ubuntu (14.04). I
don't understand if this applies to Fedora.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2017#comment:19&gt;
GRASS GIS <http://grass.osgeo.org>