Zoneminder 1.25 not building on modern GCC compilers (4.7)

Forum for questions and support relating to the 1.25.x releases only.
Locked
lpallard
Posts: 87
Joined: Fri Mar 05, 2010 10:59 pm

Zoneminder 1.25 not building on modern GCC compilers (4.7)

Post by lpallard »

Hello,

I cannot believe nobody reported this on the forums, or I totally failed to find a thread that is related. Anyways, I am trying to build ZOneminder on a slackware64-14 machine with GCC 4.7 and it fails. Apparently, this is due to the fact that "unistd.h is no longer included in libstdc++" in GCC 4.7

See http://www.linuxquestions.org/questions ... ost4993552 for some info (noit a whole lot but still).

Failing to compile ZM 1.25 with GCC4.7 seems very well known, but still the sources are not adapted to recent GCC versions. Patches are not available as well. I am not a dev so its going to be climbing a mountain barefoot for me to patch the files and make it work.'

Has anyone built ZM 1.25 with GCC 4.7+ ?? If so, how?

THe build command fails with:

root@lhost2:~/zm# make
make all-recursive
make[1]: Entering directory `/root/zm'
Making all in src
make[2]: Entering directory `/root/zm/src'
g++ -DHAVE_CONFIG_H -I. -I.. -I/usr/include -Iyes/include -Wall -Wno-sign-compare -Iyes/include -D__STDC_CONSTANT_MACROS -MT zm_logger.o -MD -MP -MF .deps/zm_logger.Tpo -c -o zm_logger.o zm_logger.cpp
zm_logger.cpp: In constructor 'Logger::Logger()':
zm_logger.cpp:112:49: error: 'isatty' was not declared in this scope
zm_logger.cpp: In member function 'void Logger::logFile(const string&)':
zm_logger.cpp:444:69: error: 'getpid' was not declared in this scope
zm_logger.cpp: In member function 'void Logger::logPrint(bool, const char*, int, int, const char*, ...)':
zm_logger.cpp:519:39: error: 'syscall' was not declared in this scope
zm_logger.cpp:521:22: error: 'getpid' was not declared in this scope
zm_logger.cpp: At global scope:
zm_logger.cpp:43:13: warning: 'void subtractTime(timeval*, timeval*)' defined but not used [-Wunused-function]
make[2]: *** [zm_logger.o] Error 1
make[2]: Leaving directory `/root/zm/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/root/zm'
make: *** [all] Error 2

GCC

root@lhost2:~/zm# gcc -v
Reading specs from /usr/lib64/gcc/x86_64-slackware-linux/4.7.1/specs
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-slackware-linux/4.7.1/lto-wrapper
Target: x86_64-slackware-linux
Configured with: ../gcc-4.7.1/configure --prefix=/usr --libdir=/usr/lib64 --mandir=/usr/man --infodir=/usr/info --enable-shared --enable-bootstrap --enable-languages=ada,c,c++,fortran,go,java,lto,objc --enable-threads=posix --enable-checking=release --enable-objc-gc --with-system-zlib --with-python-dir=/lib64/python2.7/site-packages --disable-libunwind-exceptions --enable-__cxa_atexit --enable-libssp --enable-lto --with-gnu-ld --verbose --enable-java-home --with-java-home=/usr/lib64/jvm/jre --with-jvm-root-dir=/usr/lib64/jvm --with-jvm-jar-dir=/usr/lib64/jvm/jvm-exports --with-arch-directory=amd64 --with-antlr-jar=/slack/TMPTMPTMP/gcc-round-two/antlr-runtime-3.4.jar --enable-java-awt=gtk --disable-gtktest --disable-multilib --target=x86_64-slackware-linux --build=x86_64-slackware-linux --host=x86_64-slackware-linux
Thread model: posix
gcc version 4.7.1 (GCC)
lpallard
Posts: 87
Joined: Fri Mar 05, 2010 10:59 pm

Re: Zoneminder 1.25 not building on modern GCC compilers (4.

Post by lpallard »

I have sent an email to the Devs hoping someone will help...
User avatar
knight-of-ni
Posts: 2404
Joined: Thu Oct 18, 2007 1:55 pm
Location: Shiloh, IL

Re: Zoneminder 1.25 not building on modern GCC compilers (4.

Post by knight-of-ni »

I run Zoneminder on Centos 6, which uses GCC 4.4.7 so I don't have first hand experience of the issue you have identified.

However, I install Zoneminder via a custom-rolled RPM, and the spec file I started with came from the Fedora repository. Low and behold, the spec file references a zoneminder-1.25.0-gcc47.patch file.

Here are the contents of that patch file, which should also work for you:

Code: Select all

diff -up ./src/zm_local_camera.cpp.gcc47 ./src/zm_local_camera.cpp
--- ./src/zm_local_camera.cpp.gcc47	2011-06-21 04:19:10.000000000 -0500
+++ ./src/zm_local_camera.cpp	2012-01-19 13:43:49.142440717 -0600
@@ -26,6 +26,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
+#include <limits.h>
 #include <unistd.h>
 #include <sys/mman.h>
 #include <errno.h>
diff -up ./src/zm_logger.cpp.gcc47 ./src/zm_logger.cpp
--- ./src/zm_logger.cpp.gcc47	2011-06-28 06:07:35.000000000 -0500
+++ ./src/zm_logger.cpp	2012-01-19 13:43:49.142440717 -0600
@@ -33,6 +33,7 @@
 #include <signal.h>
 #include <stdarg.h>
 #include <errno.h>
+#include <unistd.h>
 
 bool Logger::smInitialised = false;
 Logger *Logger::smInstance = 0;
diff -up ./src/zm_thread.h.gcc47 ./src/zm_thread.h
--- ./src/zm_thread.h.gcc47	2012-01-19 13:44:43.082766722 -0600
+++ ./src/zm_thread.h	2012-01-19 13:44:56.966335869 -0600
@@ -21,6 +21,7 @@
 #define ZM_THREAD_H
 
 #include <pthread.h>
+#include <unistd.h>
 #include "zm_exception.h"
 #include "zm_utils.h"
 
EDIT: Spelling
Visit my blog for ZoneMinder related projects using the Raspberry Pi, Orange Pi, Odroid, and the ESP8266
All of these can be found at https://zoneminder.blogspot.com/
lpallard
Posts: 87
Joined: Fri Mar 05, 2010 10:59 pm

Re: Zoneminder 1.25 not building on modern GCC compilers (4.

Post by lpallard »

knnniieggt

I have applied the patch as you provided and it seems to have patched fine. ./configure goes well and finishes without errors but make throws a lot of errors:

[code]g++ -DHAVE_CONFIG_H -I. -I.. -I/usr/include -I/usr/include -Wall -Wno-sign-compare -I/usr/include -g -O2 -MT zm_file_camera.o -MD -MP -MF .deps/zm_file_camera.Tpo -c -o zm_file_camera.o zm_file_camera.cpp
mv -f .deps/zm_file_camera.Tpo .deps/zm_file_camera.Po
g++ -DHAVE_CONFIG_H -I. -I.. -I/usr/include -I/usr/include -Wall -Wno-sign-compare -I/usr/include -g -O2 -MT zm_ffmpeg_camera.o -MD -MP -MF .deps/zm_ffmpeg_camera.Tpo -c -o zm_ffmpeg_camera.o zm_ffmpeg_camera.cpp
zm_ffmpeg_camera.cpp:105:44: error: missing binary operator before token "("
In file included from zm_ffmpeg_camera.cpp:24:0:
zm_ffmpeg_camera.h:39:5: error: 'AVFormatContext' does not name a type
zm_ffmpeg_camera.h:41:5: error: 'AVCodecContext' does not name a type
zm_ffmpeg_camera.h:42:5: error: 'AVCodec' does not name a type
zm_ffmpeg_camera.h:44:5: error: 'AVFrame' does not name a type
zm_ffmpeg_camera.h:45:5: error: 'AVFrame' does not name a type
zm_ffmpeg_camera.cpp: In constructor 'FfmpegCamera::FfmpegCamera(int, const string&, int, int, int, int, int, int, int, bool)':
zm_ffmpeg_camera.cpp:35:5: error: 'mFormatContext' was not declared in this scope
zm_ffmpeg_camera.cpp:37:5: error: 'mCodecContext' was not declared in this scope
zm_ffmpeg_camera.cpp:38:5: error: 'mCodec' was not declared in this scope
zm_ffmpeg_camera.cpp:40:5: error: 'mRawFrame' was not declared in this scope
zm_ffmpeg_camera.cpp:41:5: error: 'mFrame' was not declared in this scope
zm_ffmpeg_camera.cpp: In destructor 'virtual FfmpegCamera::~FfmpegCamera()':
zm_ffmpeg_camera.cpp:46:16: error: 'mFrame' was not declared in this scope
zm_ffmpeg_camera.cpp:46:23: error: 'av_freep' was not declared in this scope
zm_ffmpeg_camera.cpp:47:16: error: 'mRawFrame' was not declared in this scope
zm_ffmpeg_camera.cpp:51:42: error: 'sws_freeContext' was not declared in this scope
zm_ffmpeg_camera.cpp:54:10: error: 'mCodecContext' was not declared in this scope
zm_ffmpeg_camera.cpp:56:37: error: 'avcodec_close' was not declared in this scope
zm_ffmpeg_camera.cpp:59:10: error: 'mFormatContext' was not declared in this scope
zm_ffmpeg_camera.cpp:61:45: error: 'av_close_input_file' was not declared in this scope
zm_ffmpeg_camera.cpp: In member function 'void FfmpegCamera::Initialise()':
zm_ffmpeg_camera.cpp:78:27: error: 'AV_LOG_DEBUG' was not declared in this scope
zm_ffmpeg_camera.cpp:78:40: error: 'av_log_set_level' was not declared in this scope
zm_ffmpeg_camera.cpp:80:27: error: 'AV_LOG_QUIET' was not declared in this scope
zm_ffmpeg_camera.cpp:80:40: error: 'av_log_set_level' was not declared in this scope
zm_ffmpeg_camera.cpp:82:21: error: 'av_register_all' was not declared in this scope
zm_ffmpeg_camera.cpp: In member function 'virtual int FfmpegCamera::PrimeCapture()':
zm_ffmpeg_camera.cpp:94:31: error: 'mFormatContext' was not declared in this scope
zm_ffmpeg_camera.cpp:94:76: error: 'av_open_input_file' was not declared in this scope
zm_ffmpeg_camera.cpp:95:9: error: 'errno' was not declared in this scope
zm_ffmpeg_camera.cpp:98:31: error: 'mFormatContext' was not declared in this scope
zm_ffmpeg_camera.cpp:98:46: error: 'av_find_stream_info' was not declared in this scope
zm_ffmpeg_camera.cpp:99:9: error: 'errno' was not declared in this scope
zm_ffmpeg_camera.cpp:103:24: error: 'mFormatContext' was not declared in this scope
zm_ffmpeg_camera.cpp:108:63: error: 'CODEC_TYPE_VIDEO' was not declared in this scope
zm_ffmpeg_camera.cpp:118:5: error: 'mCodecContext' was not declared in this scope
zm_ffmpeg_camera.cpp:118:21: error: 'mFormatContext' was not declared in this scope
zm_ffmpeg_camera.cpp:121:11: error: 'mCodec' was not declared in this scope
zm_ffmpeg_camera.cpp:121:66: error: 'avcodec_find_decoder' was not declared in this scope
zm_ffmpeg_camera.cpp:125:39: error: 'mCodec' was not declared in this scope
zm_ffmpeg_camera.cpp:125:46: error: 'avcodec_open' was not declared in this scope
zm_ffmpeg_camera.cpp:129:5: error: 'mRawFrame' was not declared in this scope
zm_ffmpeg_camera.cpp:129:37: error: 'avcodec_alloc_frame' was not declared in this scope
zm_ffmpeg_camera.cpp:132:5: error: 'mFrame' was not declared in this scope
zm_ffmpeg_camera.cpp:135:43: error: 'PIX_FMT_RGB24' was not declared in this scope
zm_ffmpeg_camera.cpp:135:102: error: 'avpicture_get_size' was not declared in this scope
zm_ffmpeg_camera.cpp:138:22: error: 'AVPicture' was not declared in this scope
zm_ffmpeg_camera.cpp:138:33: error: expected primary-expression before ')' token
zm_ffmpeg_camera.cpp:138:126: error: 'avpicture_fill' was not declared in this scope
zm_ffmpeg_camera.cpp:141:167: error: 'SWS_BICUBIC' was not declared in this scope
zm_ffmpeg_camera.cpp:141:197: error: 'sws_getCachedContext' was not declared in this scope
zm_ffmpeg_camera.cpp: In member function 'virtual int FfmpegCamera::Capture(Image&)':
zm_ffmpeg_camera.cpp:159:5: error: 'AVPacket' was not declared in this scope
zm_ffmpeg_camera.cpp:159:14: error: expected ';' before 'packet'
zm_ffmpeg_camera.cpp:163:39: error: 'mFormatContext' was not declared in this scope
zm_ffmpeg_camera.cpp:163:56: error: 'packet' was not declared in this scope
zm_ffmpeg_camera.cpp:163:63: error: 'av_read_frame' was not declared in this scope
zm_ffmpeg_camera.cpp:172:41: error: 'mCodecContext' was not declared in this scope
zm_ffmpeg_camera.cpp:172:56: error: 'mRawFrame' was not declared in this scope
zm_ffmpeg_camera.cpp:172:91: error: 'avcodec_decode_video2' was not declared in this scope
zm_ffmpeg_camera.cpp:182:50: error: 'mRawFrame' was not declared in this scope
zm_ffmpeg_camera.cpp:182:91: error: 'mCodecContext' was not declared in this scope
zm_ffmpeg_camera.cpp:182:114: error: 'mFrame' was not declared in this scope
zm_ffmpeg_camera.cpp:182:145: error: 'sws_scale' was not declared in this scope
zm_ffmpeg_camera.cpp:188:31: error: 'mCodecContext' was not declared in this scope
zm_ffmpeg_camera.cpp:188:102: error: 'mFrame' was not declared in this scope
zm_ffmpeg_camera.cpp:193:33: error: 'av_free_packet' was not declared in this scope
make[2]: *** [zm_ffmpeg_camera.o] Error 1
make[2]: Leaving directory `/root/zm/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/root/zm'
make: *** [all] Error 2
[/code]

I wonder if its caused by my ffmpeg 0.11.1 not being compatible with ZM 1.25???
User avatar
knight-of-ni
Posts: 2404
Joined: Thu Oct 18, 2007 1:55 pm
Location: Shiloh, IL

Re: Zoneminder 1.25 not building on modern GCC compilers (4.

Post by knight-of-ni »

That's correct. Zoneminder 1.25 is known not to work with modern versions of ffmpeg, including the version you are trying to use.

Now I'm sure you could spend time modding the zoneminder source to get it to compile, but I'd rather just use an older version of ffmpeg.

The version I know to work without any issue is ffmpeg-0.6.5-1 from the rpmforge repository.
Visit my blog for ZoneMinder related projects using the Raspberry Pi, Orange Pi, Odroid, and the ESP8266
All of these can be found at https://zoneminder.blogspot.com/
User avatar
knight-of-ni
Posts: 2404
Joined: Thu Oct 18, 2007 1:55 pm
Location: Shiloh, IL

Re: Zoneminder 1.25 not building on modern GCC compilers (4.

Post by knight-of-ni »

I was looking for something else when I came across this today:
http://tom.webarts.ca/Blog/new-blog-ite ... ut-libx264

Looks like he shows the necessary changes that should be made to the zm source to get it to compile with modern versions of ffmpeg.
Visit my blog for ZoneMinder related projects using the Raspberry Pi, Orange Pi, Odroid, and the ESP8266
All of these can be found at https://zoneminder.blogspot.com/
lpallard
Posts: 87
Joined: Fri Mar 05, 2010 10:59 pm

Re: Zoneminder 1.25 not building on modern GCC compilers (4.

Post by lpallard »

I will be trying that today. Obviously, if this works well, it should be pushed to the ZM devs so they can perhaps release 1.25.X or 1.26?..
lpallard
Posts: 87
Joined: Fri Mar 05, 2010 10:59 pm

Re: Zoneminder 1.25 not building on modern GCC compilers (4.

Post by lpallard »

Its not working, or alt least I failed to modify the source properly...

I still get the same output.

TO be honest, there are a few places in his procedure where I didnt know what to do. For example, he was sometimes getting errors that I wasnt. So should I modify the code like he's suggesting or not?! I did but maybe it wasnt the best to do so..

Then when he said "Now ffmpeg img_convert has been replaced with sws_scale as described in http://dranger.com/ffmpeg/tutorial08.html"

What do I do with that? I went to the link he suggested only to fond a tutorial that I dont know how to apply to my setup... I did nothing at that step and I believe I should have done something.
User avatar
knight-of-ni
Posts: 2404
Joined: Thu Oct 18, 2007 1:55 pm
Location: Shiloh, IL

Re: Zoneminder 1.25 not building on modern GCC compilers (4.

Post by knight-of-ni »

Yeah, this is why I just stick to the ffmpeg at rpmforge. Even if you get this working, you will have to revisit this issue anytime you want to upgrade ffmpeg or zoneminder on your machine.

Did you do this part?
I suspect that these are macro defines in ffmpeg somewhere so I did a search in the ffmpeg source and confirmed.
So... This is telling me that ZM is not finding the libavfomat and other libav* headers.
Maybe because ZM did not get configured correctly to set the right DEFINEs for

HAVE_LIBAVCODEC,
HAVE_LIBAVUTIL_AVUTIL_H,
HAVE_LIBAVCODEC_AVCODEC_H,
HAVE_LIBAVFORMAT_AVFORMAT_H,
HAVE_LIBSWSCALE,
HAVE_LIBSWSCALE_SWSCALE_H

See zm_ffmpeg.h included from zm_ffmpeg_camera.h

In zm_ffmeg.h in addition to the checks for the above flags
I added
#include <ffmpeg/libavutil/avutil.h>
#include <ffmpeg/libavcodec/avcodec.h>
#include <ffmpeg/libavformat/avformat.h>
#include <libswscale/swscale.h>
You first might want to verify that avutil.h, avcodec.h, etc are in the same folders as this example. Or perhaps the issue is these libraries are not installed at all.
Visit my blog for ZoneMinder related projects using the Raspberry Pi, Orange Pi, Odroid, and the ESP8266
All of these can be found at https://zoneminder.blogspot.com/
lpallard
Posts: 87
Joined: Fri Mar 05, 2010 10:59 pm

Re: Zoneminder 1.25 not building on modern GCC compilers (4.

Post by lpallard »

FYI, Ive ended up trying the latest release (1.26.3) which built and installed just fine! :D but cant get it running...

See http://www.zoneminder.com/forums/viewto ... 30&t=21479 for my new thread ;)

Thanks!!
Locked