netgen icon indicating copy to clipboard operation
netgen copied to clipboard

6.2.2404 fails to build with gcc-14: encoding.hpp: 'string' 'cerr' 'endl' has not been declared;

Open drew-parsons opened this issue 1 year ago • 2 comments

netgen 6.2.2404 fails to build on debian unstable (linux) The error message is

In file included from /build/netgen-6.2.2404+dfsg1/ng/ngpkg.cpp:58:
/build/netgen-6.2.2404+dfsg1/ng/encoding.hpp:116:15: error: 'string' has not been declared
  116 |     int Start(string filename) {
      |               ^~~~~~
/build/netgen-6.2.2404+dfsg1/ng/encoding.hpp: In member function 'int Mpeg::AddFrame()':
/build/netgen-6.2.2404+dfsg1/ng/encoding.hpp:76:23: warning: 'void av_init_packet(AVPacket*)' is deprecated [-Wdeprecated-declarations]
   76 |         av_init_packet(&pkt);
      |         ~~~~~~~~~~~~~~^~~~~~
In file included from /usr/include/x86_64-linux-gnu/libavcodec/avcodec.h:44,
                 from /build/netgen-6.2.2404+dfsg1/ng/encoding.hpp:8:
/usr/include/x86_64-linux-gnu/libavcodec/packet.h:653:6: note: declared here
  653 | void av_init_packet(AVPacket *pkt);
      |      ^~~~~~~~~~~~~~
/build/netgen-6.2.2404+dfsg1/ng/encoding.hpp:82:13: error: 'cerr' was not declared in this scope; did you mean 'std::cerr'?
   82 |             cerr << "Error encoding video frame: " << endl;
      |             ^~~~
      |             std::cerr
In file included from /build/netgen-6.2.2404+dfsg1/libsrc/include/mystdlib.h:4,
                 from /build/netgen-6.2.2404+dfsg1/ng/ngpkg.cpp:7:
/usr/include/c++/14/iostream:64:18: note: 'std::cerr' declared here
   64 |   extern ostream cerr;          ///< Linked to standard error (unbuffered)
      |                  ^~~~
/build/netgen-6.2.2404+dfsg1/ng/encoding.hpp:82:55: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   82 |             cerr << "Error encoding video frame: " << endl;
      |                                                       ^~~~
      |                                                       std::endl
In file included from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/ostream:741:5: note: 'std::endl' declared here
  741 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
...

netgen 6.2.2401 builds successfully without these errors.

Some netgen files #include <mystdlib.h>, which includes some C++ std libraries. However ng/encoding.hpp does not include mystdlib.h

Attempting to build with cmake 3.30.3 gcc 14.2.0

drew-parsons avatar Sep 15 '24 11:09 drew-parsons

This should be fixed by the debian patch, see

  1. https://sources.debian.org/src/netgen/6.2.2404%2Bdfsg1-4/debian/patches/ffmpeg_link_libraries.patch/
  2. https://sources.debian.org/src/netgen/6.2.2404%2Bdfsg1-4/debian/patches/include_stdlib.patch/

Fix me: if you are the one who made the patch.

qbisi avatar Nov 18 '24 19:11 qbisi

I've created PR #205 to apply the patch

drew-parsons avatar Jan 05 '25 11:01 drew-parsons