Building CMake 3.7.2 (and 3.12.2) failed on Ubuntu 18.04.1 LTS 32 bit machine
I'm trying to build CMake 3.7.2 on my Ubuntu 18.04.1 LTS (32 bit machine), but the first stop ./bootstrap
failed:
$ ./bootstrap
---------------------------------------------
CMake 3.7.2, Copyright 2000-2016 Kitware, Inc. and Contributors
Found GNU toolchain
C compiler on this system is: gcc
---------------------------------------------
Error when bootstrapping CMake:
Cannot find appropriate C++ compiler on this system.
Please specify one using environment variable CXX.
See cmake_bootstrap.log for compilers attempted.
---------------------------------------------
Log of errors: /home/xxx/Downloads/cmake-3.7.2/Bootstrap.cmk/cmake_bootstrap.log
This happens even if I export CXX=/usr/bin/g++
or export CXX=/usr/bin/c++
. The log file says that stdlib.h not found
and iostream.h
not found, but they are actually installed in my system as:
$ locate stdlib.h
/usr/include/stdlib.h
/usr/include/c++/5/tr1/stdlib.h
/usr/include/c++/7/stdlib.h
/usr/include/c++/7/tr1/stdlib.h
/usr/include/freetype2/freetype/config/ftstdlib.h
/usr/include/i386-linux-gnu/bits/stdlib.h
$ locate iostream.h
/usr/include/glib-2.0/gio/gfileiostream.h
/usr/include/glib-2.0/gio/giostream.h
/usr/include/glib-2.0/gio/gsimpleiostream.h
Below is the actual cmake_bootstrap.log:
Checking for GNU toolchain
Try: gcc
Line: gcc cmake_bootstrap_18664_test.c -o cmake_bootstrap_18664_test
---------- file -----------------------
int main() { return 0; }
------------------------------------------
Test succeeded
Try: g++
Line: g++ cmake_bootstrap_18664_test.cpp -o cmake_bootstrap_18664_test
---------- file -----------------------
int main() { return 0; }
------------------------------------------
Test succeeded
Try: gcc
Line: gcc cmake_bootstrap_18664_test.c -o cmake_bootstrap_18664_test
---------- file -----------------------
#ifdef __cplusplus
# error "The CMAKE_C_COMPILER is set to a C++ compiler"
#endif
#include<stdio.h>
#if defined(__CLASSIC_C__)
int main(argc, argv)
int argc;
char* argv[];
#else
int main(int argc, char* argv[])
#endif
{
printf("%d%c", (argv != 0), (char)0x0a);
return argc-1;
}
------------------------------------------
1
Test succeeded
Try: g++
Line: g++ -DTEST1 cmake_bootstrap_18664_test.cxx -o cmake_bootstrap_18664_test
---------- file -----------------------
#if defined(TEST1)
# include <iostream>
#else
# include <iostream.h>
#endif
class NeedCXX
{
public:
NeedCXX() { this->Foo = 1; }
int GetFoo() { return this->Foo; }
private:
int Foo;
};
int main()
{
NeedCXX c;
#ifdef TEST3
cout << c.GetFoo() << endl;
#else
std::cout << c.GetFoo() << std::endl;
#endif
return 0;
}
------------------------------------------
In file included from /usr/include/c++/7/ext/string_conversions.h:41:0,
from /usr/include/c++/7/bits/basic_string.h:6349,
from /usr/include/c++/7/string:52,
from /usr/include/c++/7/bits/locale_classes.h:40,
from /usr/include/c++/7/bits/ios_base.h:41,
from /usr/include/c++/7/ios:42,
from /usr/include/c++/7/ostream:38,
from /usr/include/c++/7/iostream:39,
from cmake_bootstrap_18664_test.cxx:3:
/usr/include/c++/7/cstdlib:75:15: fatal error: stdlib.h: No such file or directory
#include_next <stdlib.h>
^~~~~~~~~~
compilation terminated.
Test failed to compile
Try: g++
Line: g++ -DTEST2 cmake_bootstrap_18664_test.cxx -o cmake_bootstrap_18664_test
---------- file -----------------------
#if defined(TEST1)
# include <iostream>
#else
# include <iostream.h>
#endif
class NeedCXX
{
public:
NeedCXX() { this->Foo = 1; }
int GetFoo() { return this->Foo; }
private:
int Foo;
};
int main()
{
NeedCXX c;
#ifdef TEST3
cout << c.GetFoo() << endl;
#else
std::cout << c.GetFoo() << std::endl;
#endif
return 0;
}
------------------------------------------
cmake_bootstrap_18664_test.cxx:5:11: fatal error: iostream.h: No such file or directory
# include <iostream.h>
^~~~~~~~~~~~
compilation terminated.
Test failed to compile
Try: g++
Line: g++ -DTEST3 cmake_bootstrap_18664_test.cxx -o cmake_bootstrap_18664_test
---------- file -----------------------
#if defined(TEST1)
# include <iostream>
#else
# include <iostream.h>
#endif
class NeedCXX
{
public:
NeedCXX() { this->Foo = 1; }
int GetFoo() { return this->Foo; }
private:
int Foo;
};
int main()
{
NeedCXX c;
#ifdef TEST3
cout << c.GetFoo() << endl;
#else
std::cout << c.GetFoo() << std::endl;
#endif
return 0;
}
------------------------------------------
cmake_bootstrap_18664_test.cxx:5:11: fatal error: iostream.h: No such file or directory
# include <iostream.h>
^~~~~~~~~~~~
compilation terminated.
Test failed to compile
Similar problem happened when I tried to install CMake 3.12.2. I would greatly appreciate any help since I need at least CMake 3.7.2 for various Julia packages.