{"id":658,"date":"2016-05-26T23:27:17","date_gmt":"2016-05-26T22:27:17","guid":{"rendered":"https:\/\/pgregg.com\/blog\/?p=658"},"modified":"2016-05-26T23:32:11","modified_gmt":"2016-05-26T22:32:11","slug":"compiling-zoneminder-with-libjpeg-turbo-and-jpeg_lib_version-error","status":"publish","type":"post","link":"https:\/\/blog.pgregg.com\/blog\/2016\/05\/compiling-zoneminder-with-libjpeg-turbo-and-jpeg_lib_version-error\/","title":{"rendered":"Compiling ZoneMinder with libjpeg-turbo and JPEG_LIB_VERSION error"},"content":{"rendered":"<p>If you&#8217;ve ever tried to build ZoneMinder from source and been frustrated by the following compile error, then I hope this helps you.<\/p>\n<pre><code><small>[ 30%] Building CXX object src\/CMakeFiles\/zm.dir\/zm_image.cpp.o\r\n \/u1\/src\/ZoneMinder\/src\/zm_image.cpp: In member function \u2018bool Image::ReadRaw(const char*)\u2019:\r\n \/u1\/src\/ZoneMinder\/src\/zm_image.cpp:616:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]\r\n \/u1\/src\/ZoneMinder\/src\/zm_image.cpp: In member function \u2018bool Image::ReadJpeg(const char*, unsigned int, unsigned int)\u2019:\r\n \/u1\/src\/ZoneMinder\/src\/zm_image.cpp:664:5: error: \u2018JPEG_LIB_VERSION\u2019 was not declared in this scope\r\n \/u1\/src\/ZoneMinder\/src\/zm_image.cpp: In member function \u2018bool Image::WriteJpeg(const char*, int, timeval) const\u2019:\r\n \/u1\/src\/ZoneMinder\/src\/zm_image.cpp:825:5: error: \u2018JPEG_LIB_VERSION\u2019 was not declared in this scope\r\n \/u1\/src\/ZoneMinder\/src\/zm_image.cpp: In member function \u2018bool Image::DecodeJpeg(const JOCTET*, int, unsigned int, unsigned int)\u2019:\r\n \/u1\/src\/ZoneMinder\/src\/zm_image.cpp:956:5: error: \u2018JPEG_LIB_VERSION\u2019 was not declared in this scope\r\n \/u1\/src\/ZoneMinder\/src\/zm_image.cpp: In member function \u2018bool Image::EncodeJpeg(JOCTET*, int*, int) const\u2019:\r\n \/u1\/src\/ZoneMinder\/src\/zm_image.cpp:1090:5: error: \u2018JPEG_LIB_VERSION\u2019 was not declared in this scope\r\n make[2]: *** [src\/CMakeFiles\/zm.dir\/zm_image.cpp.o] Error 1\r\n make[1]: *** [src\/CMakeFiles\/zm.dir\/all] Error 2\r\n make: *** [all] Error 2\r\n<\/small><\/code><\/pre>\n<p>jpeglib-turbo\/include\/jconfig.h (from your installed jpeglib-turbo-dev) has:<\/p>\n<pre>#define JPEG_LIB_VERSION 62<\/pre>\n<p>And to avoid including this more than once the wrapper libjpeg-turbo\/include\/jpeglib.h has:<\/p>\n<pre>#ifndef JCONFIG_INCLUDED \/* in case jinclude.h already did *\/\r\n#include \"jconfig.h\" \/* widely used configuration options *\/\r\n#endif<\/pre>\n<p>So far so good&#8230; The problem comes when zoneminder wants to compile zm_image.cpp<\/p>\n<p>the include path is:<\/p>\n<pre>zm_image.cpp\r\n -&gt; zm_image.h\r\n   -&gt; zm_jpeg.h\r\n     -&gt; jinclude.h\r\n       -&gt; jconfig.h   (from jpeglib-turbo)\r\n     -&gt; jpeglib.h     (from jpeglib-turbo)<\/pre>\n<p>Now, this *should* all work properly! I suspect it has something to do with cmake and scope and by the time we get back to jinclude.h it no longer has the define.<\/p>\n<p>My fix was to take the version from my\u00a0jpeglib-turbo\/include\/jconfig.h and simply add it to zoneminder&#8217;s jinclude.h:<\/p>\n<pre>#include \"jconfig.h\" \/* auto configuration options *\/\r\n#define JCONFIG_INCLUDED \/* so that jpeglib.h doesn't do it again *\/\r\n\r\n<span style=\"color: #0000ff;\">#ifndef JPEG_LIB_VERSION<\/span>\r\n<span style=\"color: #0000ff;\">#define JPEG_LIB_VERSION 62<\/span>\r\n<span style=\"color: #0000ff;\">#endif<\/span><\/pre>\n<p>Add the 3 blue lines after the jconfig.h include. Once done, compile should complete properly.<\/p>\n<p>Hope this helps other get past this hurdle.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you&#8217;ve ever tried to build ZoneMinder from source and been frustrated by the following compile error, then I hope this helps you. [ 30%] Building CXX object src\/CMakeFiles\/zm.dir\/zm_image.cpp.o \/u1\/src\/ZoneMinder\/src\/zm_image.cpp: In member function \u2018bool Image::ReadRaw(const char*)\u2019: \/u1\/src\/ZoneMinder\/src\/zm_image.cpp:616:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] \/u1\/src\/ZoneMinder\/src\/zm_image.cpp: In member function \u2018bool Image::ReadJpeg(const char*, unsigned int, &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/blog.pgregg.com\/blog\/2016\/05\/compiling-zoneminder-with-libjpeg-turbo-and-jpeg_lib_version-error\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Compiling ZoneMinder with libjpeg-turbo and JPEG_LIB_VERSION error&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[11,12],"tags":[123,122,121],"class_list":["post-658","post","type-post","status-publish","format-standard","hentry","category-software","category-systems","tag-compiling","tag-libjpeg-turbo","tag-zoneminder"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pbQOUu-aC","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/blog.pgregg.com\/blog\/wp-json\/wp\/v2\/posts\/658","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.pgregg.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.pgregg.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.pgregg.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.pgregg.com\/blog\/wp-json\/wp\/v2\/comments?post=658"}],"version-history":[{"count":2,"href":"https:\/\/blog.pgregg.com\/blog\/wp-json\/wp\/v2\/posts\/658\/revisions"}],"predecessor-version":[{"id":660,"href":"https:\/\/blog.pgregg.com\/blog\/wp-json\/wp\/v2\/posts\/658\/revisions\/660"}],"wp:attachment":[{"href":"https:\/\/blog.pgregg.com\/blog\/wp-json\/wp\/v2\/media?parent=658"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.pgregg.com\/blog\/wp-json\/wp\/v2\/categories?post=658"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.pgregg.com\/blog\/wp-json\/wp\/v2\/tags?post=658"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}