ZLIB_CFLAGS issue on Ubuntu 16.04 LTS

linux
installation

#1

Hi there,

I’ve been reading through other posts regarding ./configure and zlib, but it was running on Windows (Error relating to C++ compiler when running ./configure on Windows). I’m having the same issue, but on linux.

I have been looking at the configure.log output after modifying the ZLIB_CFLAGS environment, but I keep getting error messages. The following is the furthest I have been able to get.

The terminal input in the mrtrix3 folder:
export ZLIB_CFLAGS="-isystem /usr/src/linux-headers-4.4.0-31/include/linux" ZLIB_CFLAGS="-isystem /usr/src/linux-headers-4.4.0-31/include/uapi/linux" ./configure

The corresponding configure.log says:

REPORT: 
MRtrix build type requested:

REPORT: release

REPORT: 

REPORT: Detecting OS: linux

REPORT: Checking for C++11 compliant compiler [g++]:
EXEC <<
CMD: g++ -dumpversion
EXIT: 0
STDOUT:
5.4.0
>>


REPORT: 5.4.0

COMPILE /tmp/tmp7mk4FS.cpp:
---

struct Base {
    Base (int);
};
struct Derived : Base {
    using Base::Base;
};

int main() {
  Derived D (int); // check for contructor inheritance
  return (0);
}

---
EXEC <<
CMD: g++ -c -std=c++11 -mno-avx -pthread -fPIC -march=native /tmp/tmp7mk4FS.cpp -o /tmp/tmp7mk4FS.o
EXIT: 0
>>

EXEC <<
CMD: g++ /tmp/tmp7mk4FS.o -pthread -o a.out
EXIT: 0
>>

EXEC <<
CMD: ./a.out
EXIT: 0
>>


REPORT:  - tested ok

REPORT: Detecting pointer size:

COMPILE /tmp/tmp6v2nXS.cpp:
---

#include <iostream>
int main() {
  std::cout << sizeof(void*);
  return (0);
}

---
EXEC <<
CMD: g++ -c -std=c++11 -mno-avx -pthread -fPIC -march=native /tmp/tmp6v2nXS.cpp -o /tmp/tmp6v2nXS.o
EXIT: 0
>>

EXEC <<
CMD: g++ /tmp/tmp6v2nXS.o -pthread -o a.out
EXIT: 0
>>

EXEC <<
CMD: ./a.out
EXIT: 0
STDOUT:
8
>>


REPORT: 64 bit

REPORT: Detecting byte order:

REPORT: little-endian

REPORT: Checking for variable-length array support:

COMPILE /tmp/tmpdUKgH2.cpp:
---


int main(int argc, char* argv[]) {
  int x[argc];
  return 0;
}

---
EXEC <<
CMD: g++ -c -std=c++11 -mno-avx -pthread -fPIC -march=native -DMRTRIX_WORD64 /tmp/tmpdUKgH2.cpp -o /tmp/tmpdUKgH2.o
EXIT: 0
>>

EXEC <<
CMD: g++ /tmp/tmpdUKgH2.o -pthread -o a.out
EXIT: 0
>>

EXEC <<
CMD: ./a.out
EXIT: 0
>>


REPORT: yes

REPORT: Checking for non-POD variable-length array support:

COMPILE /tmp/tmpaPgRVB.cpp:
---

#include <string>

class X {
  int x;
  double y;
  std::string s;
};

int main(int argc, char* argv[]) {
  X x[argc];
  return 0;
}

---
EXEC <<
CMD: g++ -c -std=c++11 -mno-avx -pthread -fPIC -march=native -DMRTRIX_WORD64 /tmp/tmpaPgRVB.cpp -o /tmp/tmpaPgRVB.o
EXIT: 0
>>

EXEC <<
CMD: g++ /tmp/tmpaPgRVB.o -pthread -o a.out
EXIT: 0
>>

EXEC <<
CMD: ./a.out
EXIT: 0
>>


REPORT: yes

REPORT: Checking for zlib compression library:

COMPILE /tmp/tmpCaB_8W.cpp:
---

#include <iostream>
#include <zlib.h>

int main() {
  std::cout << zlibVersion();
  return (0);
}

---
EXEC <<
CMD: g++ -c -std=c++11 -mno-avx -pthread -fPIC -march=native -DMRTRIX_WORD64 -isystem /usr/src/linux-headers-4.4.0-31/include/uapi/linux /tmp/tmpCaB_8W.cpp -o /tmp/tmpCaB_8W.o
EXIT: 1
STDERR:
In file included from /usr/include/wchar.h:51:0,
                 from /usr/include/c++/5/cwchar:44,
                 from /usr/include/c++/5/bits/postypes.h:40,
                 from /usr/include/c++/5/iosfwd:40,
                 from /usr/include/c++/5/ios:38,
                 from /usr/include/c++/5/ostream:38,
                 from /usr/include/c++/5/iostream:39,
                 from /tmp/tmpCaB_8W.cpp:2:
/usr/src/linux-headers-4.4.0-31/include/uapi/linux/stddef.h:1:28: fatal error: linux/compiler.h: No such file or directory
compilation terminated.
>>

error deleting temporary file "/tmp/tmpCaB_8W.o": No such file or directory
ERROR: error compiling zlib application!

  MRtrix3 was unable to compile a test program involving zlib.

  Set the ZLIB_CFLAGS environment variable to inform 'configure' of
  the flags it must provide to the compiler in order to compile
  programs that use zlib functionality; this may include the path to
  the zlib include files, as well as any required flags.
  For example:
    $ export ZLIB_CFLAGS="-isystem /usr/local/include"
    $./configure
  (amend with the actual path to the zlib include files on your system)`

The linux/compiler.h file is located in /usr/src/linux-headers-4.4.0-31/include/linux, but I haven’t been able to reference the the environment back to that folder.

I’m stumped as how to proceed. Any help is much appreciated!

Thanks!!
Lucia


#2

There should not be any need to specify the ZLIB_CFLAGS on Ubuntu 16.04. You should be able to simply follow the general Linux instructions (http://mrtrix.readthedocs.io/en/latest/installation/linux_install.html). Why do you need to manually specify these flags? Did you run into any issues when simply running ./configure ? (Note that you should close your terminal or unset the ZLIB_CFLAGS variable before trying this)


#3

Like @bjeurissen says, there shouldn’t be any need to supply any additional flags on Ubuntu 16.04, provided the right packages are installed. The configure.log output you posted is unfortunately no use here, since the errors shown most likely relate to the fact that you’ve added in these flags. For instance, your first export statement:

export ZLIB_CFLAGS="-isystem /usr/src/linux-headers-4.4.0-31/include/linux" 

is immediately overridden by the very next command:

ZLIB_CFLAGS="-isystem /usr/src/linux-headers-4.4.0-31/include/uapi/linux"
./configure

So has no effect - which is probably why the script still can’t find the linux/compiler.h file.

Furthermore, the missing header file seems to be required when including <iostream>, yet one of the earlier tests (for pointer size) includes that same header and compiles just fine. So this is likely not to be the problem.

Also, a quick search on Google shows that most people only encounter this error when building kernel modules, which requires quite specific settings. This simply should not be happening here when building regular executables.

So I’m not sure what prompted you to add these particular flags, but if you post the output of a straight ./configure in a fresh terminal, as @bjeurissen suggests, then we might be able to figure out the actual problem. My guess is you might be missing the zlib1g-dev package (note that it might be called something else, haven’t checked for a while) if the error was initially at the zlib configure stage.


#4

@bjeurissen @jdtournier To clarify as to why I altered the ZLIB_CFLAGS, I did have an issue when running ./configure by itself.

This is what I get I get in terminal when I run ./configure:
` MRtrix build type requested: release

Detecting OS: linux
Checking for C++11 compliant compiler [g++]: 5.4.0 - tested ok
Detecting pointer size: 64 bit
Detecting byte order: little-endian
Checking for variable-length array support: yes
Checking for non-POD variable-length array support: yes
Checking for zlib compression library: 
ERROR: error compiling zlib application!

  MRtrix3 was unable to compile a test program involving zlib.

  Set the ZLIB_CFLAGS environment variable to inform 'configure' of
  the flags it must provide to the compiler in order to compile
  programs that use zlib functionality; this may include the path to
  the zlib include files, as well as any required flags.
  For example:
    $ export ZLIB_CFLAGS="-isystem /usr/local/include"
    $./configure
  (amend with the actual path to the zlib include files on your system)`

The corresponding configure.log shows this:

REPORT: 
MRtrix build type requested:

REPORT: release

REPORT: 

REPORT: Detecting OS: linux

REPORT: Checking for C++11 compliant compiler [g++]:
EXEC <<
CMD: g++ -dumpversion
EXIT: 0
STDOUT:
5.4.0
>>


REPORT: 5.4.0

COMPILE /tmp/tmpwkEOAO.cpp:
---

struct Base {
    Base (int);
};
struct Derived : Base {
    using Base::Base;
};

int main() {
  Derived D (int); // check for contructor inheritance
  return (0);
}

---
EXEC <<
CMD: g++ -c -std=c++11 -mno-avx -pthread -fPIC -march=native /tmp/tmpwkEOAO.cpp -o /tmp/tmpwkEOAO.o
EXIT: 0
>>

EXEC <<
CMD: g++ /tmp/tmpwkEOAO.o -pthread -o a.out
EXIT: 0
>>

EXEC <<
CMD: ./a.out
EXIT: 0
>>


REPORT:  - tested ok

REPORT: Detecting pointer size:

COMPILE /tmp/tmpXYiwd0.cpp:
---

#include <iostream>
int main() {
  std::cout << sizeof(void*);
  return (0);
}

---
EXEC <<
CMD: g++ -c -std=c++11 -mno-avx -pthread -fPIC -march=native /tmp/tmpXYiwd0.cpp -o /tmp/tmpXYiwd0.o
EXIT: 0
>>

EXEC <<
CMD: g++ /tmp/tmpXYiwd0.o -pthread -o a.out
EXIT: 0
>>

EXEC <<
CMD: ./a.out
EXIT: 0
STDOUT:
8
>>


REPORT: 64 bit

REPORT: Detecting byte order:

REPORT: little-endian

REPORT: Checking for variable-length array support:

COMPILE /tmp/tmpoPPnca.cpp:
---


int main(int argc, char* argv[]) {
  int x[argc];
  return 0;
}

---
EXEC <<
CMD: g++ -c -std=c++11 -mno-avx -pthread -fPIC -march=native -DMRTRIX_WORD64 /tmp/tmpoPPnca.cpp -o /tmp/tmpoPPnca.o
EXIT: 0
>>

EXEC <<
CMD: g++ /tmp/tmpoPPnca.o -pthread -o a.out
EXIT: 0
>>

EXEC <<
CMD: ./a.out
EXIT: 0
>>


REPORT: yes

REPORT: Checking for non-POD variable-length array support:

COMPILE /tmp/tmptZVkoO.cpp:
---

#include <string>

class X {
  int x;
  double y;
  std::string s;
};

int main(int argc, char* argv[]) {
  X x[argc];
  return 0;
}

---
EXEC <<
CMD: g++ -c -std=c++11 -mno-avx -pthread -fPIC -march=native -DMRTRIX_WORD64 /tmp/tmptZVkoO.cpp -o /tmp/tmptZVkoO.o
EXIT: 0
>>

EXEC <<
CMD: g++ /tmp/tmptZVkoO.o -pthread -o a.out
EXIT: 0
>>

EXEC <<
CMD: ./a.out
EXIT: 0
>>


REPORT: yes

REPORT: Checking for zlib compression library:

COMPILE /tmp/tmpce3AKX.cpp:
---

#include <iostream>
#include <zlib.h>

int main() {
  std::cout << zlibVersion();
  return (0);
}

---
EXEC <<
CMD: g++ -c -std=c++11 -mno-avx -pthread -fPIC -march=native -DMRTRIX_WORD64 /tmp/tmpce3AKX.cpp -o /tmp/tmpce3AKX.o
EXIT: 1
STDERR:
/tmp/tmpce3AKX.cpp:3:18: fatal error: zlib.h: No such file or directory
compilation terminated.
>>

error deleting temporary file "/tmp/tmpce3AKX.o": No such file or directory
ERROR: error compiling zlib application!

  MRtrix3 was unable to compile a test program involving zlib.

  Set the ZLIB_CFLAGS environment variable to inform 'configure' of
  the flags it must provide to the compiler in order to compile
  programs that use zlib functionality; this may include the path to
  the zlib include files, as well as any required flags.
  For example:
    $ export ZLIB_CFLAGS="-isystem /usr/local/include"
    $./configure`
  (amend with the actual path to the zlib include files on your system)`

Prior to installing MRtrix3, I installed the necessary packages as per the installation instructions, including zlib1g-dev. I just ran sudo apt-get install zlib1g-dev to check if it was installed. Terminal gave me this:
Reading package lists... Done Building dependency tree Reading state information... Done zlib1g-dev is already the newest version (1:1.2.8.dfsg-2ubuntu4). 0 upgraged, 0 newly installed, 0 to remove 292 not upgraded

I assumed listing two ZLIB_CFLAGS consecutively might negate the other, but it did take me a step further than the initial error. Wasn’t exactly the best way to set up the environments…

I’m currently running the upgrades to see if my error has something to do with that, but it could also be unrelated. Worth a try.

Thanks for your responses!


#5

The upgrade fixed the zlib problem, but I’m getting an Eigen3 error now. I noticed there’s already a thread for that, so I’m going to check that out.

Thanks for taking the time to look at this!