Forum

Bug in the build-mechanism

Rene
2 June 2014, 13:48
Hello,

i have found a Bug in the Build-Mechanism

I build the Makefile with

cmake \
-DENABLE_CACHE=ON \
-DENABLE_DEBUG=OFF \
-DENABLE_IPV6=OFF \
-DENABLE_MONITOR=OFF \
-DENABLE_RPROXY=ON \
-DENABLE_SSL=ON \
-DENABLE_TOOLKIT=ON \
-DENABLE_XSLT=OFF \
-DCONFIG_DIR=/etc/service/www/conf \
-DLOG_DIR=/var/log/www \
-DPID_DIR=/var/run \
-DWEBROOT_DIR=/var/www/default \
-DWORK_DIR=/tmp/hiawatha

type 'make' and becomes an error:

[ 75%] Building C object CMakeFiles/hiawatha.dir/src/log.c.o
/src/hiawatha-9.6/src/log.c:20:18: fatal error: zlib.h: file or directory not found
compilation terminated.

uname -a
Linux xxx 3.2.0-4-amd64 #1 SMP Debian 3.2.57-3 x86_64 GNU/Linux

Hiawatha version: 9.6
Operating System: Debian
Rene
2 June 2014, 13:48
Hello,

after i installed zlib1g-dev it stopped on linking with error:

[ 87%] Building C object CMakeFiles/hiawatha.dir/src/xslt.c.o
Linking C executable hiawatha
CMakeFiles/hiawatha.dir/src/log.c.o: In function `gzip_logfile':
/src/hiawatha-9.6/src/log.c:548: undefined reference to `gzdopen'
/src/hiawatha-9.6/src/log.c:564: undefined reference to `gzwrite'
/src/hiawatha-9.6/src/log.c:575: undefined reference to `gzclose'
collect2: error: ld returned 1 exit status
make[2]: *** [hiawatha] Fehler 1
make[1]: *** [CMakeFiles/hiawatha.dir/all] Fehler 2
make: *** [all] Fehler 2
Hugo Leisink
2 June 2014, 13:51
Does it work when running the extra/make_debian_package script?
Rene
2 June 2014, 15:31
Hello,

yes, this Script creates an .deb-Packages without any errors. I do not like to install the package. My approach previously was to build hiawatha and call it directly from build-dir. So i have all Sources and i can switch back in seconds, if a new version have an error.
Rene
2 June 2014, 15:48
after i play with HAVE_Z_LIBRARY in log.c -> gzip_logfile() and monitor.c -> flush_monitor_buffer() it compiles and link to an binary.

Here is my patch:
diff -rupN /src/hiawatha-9.6/src/log.c /src/hiawatha-9.6-dev/src/log.c
--- /src/hiawatha-9.6/src/log.c 2014-06-01 10:03:18.000000000 +0200
+++ /src/hiawatha-9.6-dev/src/log.c 2014-06-02 15:43:14.979966267 +0200
@@ -17,7 +17,9 @@
#include <stdarg.h>
#include <unistd.h>
#include <fcntl.h>
-#include <zlib.h>
+#ifdef HAVE_Z_LIBRARY
+ #include <zlib.h>
+#endif
#include <errno.h>
#include <string.h>
#include <time.h>
@@ -522,6 +524,7 @@ static int gzip_logfile(char *file) {
int result = -1, fd_in = -1, fd_out = -1;
int bytes_read, bytes_written, total_written;
struct stat stat_in;
+#ifdef HAVE_Z_LIBRARY
gzFile gzhandle = NULL;

/* Input file
@@ -595,6 +598,7 @@ gzip_fail:
if (gz_file != NULL) {
free(gz_file);
}
+#endif

return result;
}
diff -rupN /src/hiawatha-9.6/src/monitor.c /src/hiawatha-9.6-dev/src/monitor.c
--- /src/hiawatha-9.6/src/monitor.c 2014-06-01 10:03:18.000000000 +0200
+++ /src/hiawatha-9.6-dev/src/monitor.c 2014-06-02 15:44:15.396447887 +0200
@@ -23,7 +23,9 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <pthread.h>
-#include <zlib.h>
+#ifdef HAVE_Z_LIBRARY
+ #include <zlib.h>
+#endif
#include "global.h"
#include "monitor.h"
#include "libstr.h"
@@ -80,6 +82,8 @@ static void reset_cgi_stats(t_monitor_ho
*/
static int flush_monitor_buffer(void) {
int handle, bytes_written, total_written;
+
+#ifdef HAVE_Z_LIBRARY
gzFile gzhandle;

if (monitor_buffer_size == 0) {
@@ -113,7 +117,7 @@ static int flush_monitor_buffer(void) {
if (gzclose(gzhandle) != Z_OK) {
close(handle);
}
-
+#endif
monitor_buffer_size = 0;

return 0;
Hugo Leisink
2 June 2014, 15:59
This patch can't be the right solution. If the extra/make_debian_package works, it proofs that zlib is present on your system. For some reason, something goes wrong during manual compilation. I have no idea what. Are you using gcc or clang?
Rene
2 June 2014, 16:05
yes, this patch is an hack. I use gcc, installed with as Debian Package:

gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.7/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.7.2-5' --with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs --enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.7 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.7 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --with-arch-32=i586 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.7.2 (Debian 4.7.2-5)
Hugo Leisink
2 June 2014, 16:07
Does /usr/include/zlib.h exist on your system?
What is the value of the CC environment setting?
Does it compile with clang?
Chris Wadge
2 June 2014, 19:34
Not very helpful, I know, but it might be worth noting that I'm compiling on Debian with no issues...
Rene
3 June 2014, 08:00
* the File /usr/include/zlib.h exists
* `set | grep CC`is empty
* with clang (version 3.0-6.2) it compiles perfectly
Hugo Leisink
3 June 2014, 08:03
If /usr/include/zlib.h exists, I don't know why gcc says that it doesn't. The directory /usr/include should be default be in your include paths. Sounds to me something is wrong with your system. Anyway, keep CC set to clang, as clang has a better future than gcc. Won't be surprised if many distro's will mark gcc deprecated within a few years.
Rene
4 June 2014, 09:16
ok, thanks for the help!
This topic has been closed.