LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux From Scratch (https://www.linuxquestions.org/questions/linux-from-scratch-13/)
-   -   Cant build CMake - Error when bootstrapping, cannot find C++ compiler + related stdlib.h errors (BLFS 8.1) (https://www.linuxquestions.org/questions/linux-from-scratch-13/cant-build-cmake-error-when-bootstrapping-cannot-find-c-compiler-related-stdlib-h-errors-blfs-8-1-a-4175619201/)

vinto 12-08-2017 10:51 AM

Cant build CMake - Error when bootstrapping, cannot find C++ compiler + related stdlib.h errors (BLFS 8.1)
 
I am trying to build CMake using the instructions in BLFS 8.1. My LFS build is 8.1. Hopefully this is not too verbose, I just want to include anything potentially relevant. The following is what happens initially:

Code:

root [ /sources/xc/cmake-3.9.1 ]# sed -i '/CMAKE_USE_LIBUV 1/s/1/0/' CMakeLists.txt    &&
> sed -i '/"lib64"/s/64//' Modules/GNUInstallDirs.cmake &&
>
> ./bootstrap --prefix=/usr        \
>            --system-libs        \
>            --mandir=/share/man  \
>            --no-system-jsoncpp  \
>            --no-system-librhash \
>            --docdir=/share/doc/cmake-3.9.1 &&
> make
---------------------------------------------
CMake 3.9.1, Copyright 2000-2017 Kitware, Inc. and Contributors
Found GNU toolchain
C compiler on this system is: gcc  -std=gnu11
---------------------------------------------
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: /sources/xc/cmake-3.9.1/Bootstrap.cmk/cmake_bootstrap.log

I tried setting CXX (CXX="g++" and when that failed CXX="/usr/bin/g++") but no use.

The following is the error log cmake_bootstrap.log
Code:

Checking for GNU toolchain
Try: gcc
Line: gcc  cmake_bootstrap_14543_test.c -o cmake_bootstrap_14543_test
----------  file  -----------------------
int main() { return 0; }
------------------------------------------
Test succeeded
Try: g++
Line: g++  cmake_bootstrap_14543_test.cpp -o cmake_bootstrap_14543_test
----------  file  -----------------------
int main() { return 0; }
------------------------------------------
Test succeeded
Try: gcc
Line: gcc  cmake_bootstrap_14543_test.c -o cmake_bootstrap_14543_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
Checking whether gcc supports -std=gnu11
Try: gcc
Line: gcc  -std=gnu11 cmake_bootstrap_14543_test.c -o cmake_bootstrap_14543_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_14543_test.cxx -o cmake_bootstrap_14543_test
----------  file  -----------------------

#if defined(TEST1)
# include <iostream>
#else
# include <iostream.h>
#endif

#if __cplusplus >= 201103L && defined(__SUNPRO_CC) && __SUNPRO_CC < 0x5140
#error "SunPro <= 5.13 C++ 11 mode not supported due to bug in move semantics."
#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.2.0/ext/string_conversions.h:41:0,
                from /usr/include/c++/7.2.0/bits/basic_string.h:6159,
                from /usr/include/c++/7.2.0/string:52,
                from /usr/include/c++/7.2.0/bits/locale_classes.h:40,
                from /usr/include/c++/7.2.0/bits/ios_base.h:41,
                from /usr/include/c++/7.2.0/ios:42,
                from /usr/include/c++/7.2.0/ostream:38,
                from /usr/include/c++/7.2.0/iostream:39,
                from cmake_bootstrap_14543_test.cxx:3:
/usr/include/c++/7.2.0/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_14543_test.cxx -o cmake_bootstrap_14543_test
----------  file  -----------------------

#if defined(TEST1)
# include <iostream>
#else
# include <iostream.h>
#endif

#if __cplusplus >= 201103L && defined(__SUNPRO_CC) && __SUNPRO_CC < 0x5140
#error "SunPro <= 5.13 C++ 11 mode not supported due to bug in move semantics."
#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_14543_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_14543_test.cxx -o cmake_bootstrap_14543_test
----------  file  -----------------------

#if defined(TEST1)
# include <iostream>
#else
# include <iostream.h>
#endif

#if __cplusplus >= 201103L && defined(__SUNPRO_CC) && __SUNPRO_CC < 0x5140
#error "SunPro <= 5.13 C++ 11 mode not supported due to bug in move semantics."
#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_14543_test.cxx:5:11: fatal error: iostream.h: No such file or directory
 # include <iostream.h>
          ^~~~~~~~~~~~
compilation terminated.
Test failed to compile
Checking for wheter  supports -std=gnu++14
Try:
Line:  -std=gnu++14 -DTEST1 cmake_bootstrap_14543_test.cxx -o cmake_bootstrap_14543_test
----------  file  -----------------------

#if defined(TEST1)
# include <iostream>
#else
# include <iostream.h>
#endif

#if __cplusplus >= 201103L && defined(__SUNPRO_CC) && __SUNPRO_CC < 0x5140
#error "SunPro <= 5.13 C++ 11 mode not supported due to bug in move semantics."
#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;
}

------------------------------------------
./bootstrap: line 677: : command not found
Test failed to compile
Checking for wheter  supports -std=gnu++1y
Try:
Line:  -std=gnu++1y -DTEST1 cmake_bootstrap_14543_test.cxx -o cmake_bootstrap_14543_test
----------  file  -----------------------

#if defined(TEST1)
# include <iostream>
#else
# include <iostream.h>
#endif

#if __cplusplus >= 201103L && defined(__SUNPRO_CC) && __SUNPRO_CC < 0x5140
#error "SunPro <= 5.13 C++ 11 mode not supported due to bug in move semantics."
#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;
}

------------------------------------------
./bootstrap: line 677: : command not found
Test failed to compile
Checking for wheter  supports -std=gnu++11
Try:
Line:  -std=gnu++11 -DTEST1 cmake_bootstrap_14543_test.cxx -o cmake_bootstrap_14543_test
----------  file  -----------------------

#if defined(TEST1)
# include <iostream>
#else
# include <iostream.h>
#endif

#if __cplusplus >= 201103L && defined(__SUNPRO_CC) && __SUNPRO_CC < 0x5140
#error "SunPro <= 5.13 C++ 11 mode not supported due to bug in move semantics."
#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;
}

------------------------------------------
./bootstrap: line 677: : command not found
Test failed to compile
Checking for wheter  supports -std=gnu++0x
Try:
Line:  -std=gnu++0x -DTEST1 cmake_bootstrap_14543_test.cxx -o cmake_bootstrap_14543_test
----------  file  -----------------------

#if defined(TEST1)
# include <iostream>
#else
# include <iostream.h>
#endif

#if __cplusplus >= 201103L && defined(__SUNPRO_CC) && __SUNPRO_CC < 0x5140
#error "SunPro <= 5.13 C++ 11 mode not supported due to bug in move semantics."
#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;
}

------------------------------------------
./bootstrap: line 677: : command not found
Test failed to compile
Checking for wheter  supports -std=gnu++98
Try:
Line:  -std=gnu++98 -DTEST1 cmake_bootstrap_14543_test.cxx -o cmake_bootstrap_14543_test
----------  file  -----------------------

#if defined(TEST1)
# include <iostream>
#else
# include <iostream.h>
#endif

#if __cplusplus >= 201103L && defined(__SUNPRO_CC) && __SUNPRO_CC < 0x5140
#error "SunPro <= 5.13 C++ 11 mode not supported due to bug in move semantics."
#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;
}

------------------------------------------
./bootstrap: line 677: : command not found
Test failed to compile

Line 677 referenced in the above is as follows:
Code:

671TMPFILE=`cmake_tmp_file`
 672 echo "Try: ${COMPILER}"
 673 echo "Line: ${COMPILER} ${FLAGS} ${TESTFILE} -o ${TMPFILE}"
 674 echo "----------  file  -----------------------"
 675 cat "${TESTFILE}"
 676 echo "------------------------------------------"
677 "${COMPILER}" ${FLAGS} "${TESTFILE}" -o "${TMPFILE}"
 679 RES=$?
 700 if [ "${RES}" -ne "0" ]; then
 701  echo "Test failed to compile"
    return 1
  fi

I've spent all day on this, and I was able to get past the initial glitch but by ading g++ to line 991 of the file entitled cmake-3.9.1/bootstrap:
Code:

990 # Test CXX compiler
991 cmake_cxx_compiler=g++

It seemed to recognize g++ (Probably!), but it did not get much further before arriving at the following error:
Code:

no such file or directory
 #include_next <stdlib.h>
              ^~~~~~~~~~
compilation terminated.
make: *** [Makefile:4: cmAddCustomCommandCommand.o] Error 1

After hours of tinkering with it, trying older and newer versions etc., I decided perhaps I should reinstall g++. So I did so as per the LFS directions for the 3rd pass minus the removal of the symlink (since that has been done).

GCC passed config but failed to compile with the exact same error

Code:

c -I../../gcc/build -I../../gcc/../include  -I../../gcc/../libcpp/include  \
        -o build/genmddeps.o ../../gcc/genmddeps.c
In file included from ../../gcc/system.h:266:0,
                from ../../gcc/genmddeps.c:19:
/usr/include/c++/7.2.0/cstdlib:75:15: fatal error: stdlib.h: No such file or directory
#include_next <stdlib.h>
              ^~~~~~~~~~
compilation terminated.
make[2]: *** [Makefile:2595: build/genmddeps.o] Error 1

The line referenced to in cstdlib is:
Code:

72 // Need to ensure this finds the C library's <stdlib.h> not a libstdc++
73 // wrapper that might already be installed later in the include search path.
74 #define _GLIBCXX_INCLUDE_NEXT_C_HEADERS
75 #include_next <stdlib.h>
76 #undef _GLIBCXX_INCLUDE_NEXT_C_HEADERS


Something seems wrong with my g++ or corresponding libraries.

I tried reinstalling libstdc++, it succeeded. Still, the same errors when I try to compile CMake, and I tested, GCC too (failed again).

I need to be able to build cmake because some programs that I need depend on it.

Any ideas what may be going wrong?

sr_ls_boy 12-08-2017 07:46 PM

There appears to be something wrong with your glibc install.
Verify that you indeed have stdlib.h and that it is placed in
/usr/include. Do not confuse that header with the header with
the same name installed by gcc to /usr/include/c++/7.2.0.

vinto 12-09-2017 03:43 AM

Quote:

Originally Posted by sr_ls_boy (Post 5790763)
There appears to be something wrong with your glibc install.
Verify that you indeed have stdlib.h and that it is placed in
/usr/include. Do not confuse that header with the header with
the same name installed by gcc to /usr/include/c++/7.2.0.

It appears stdlib.h is installed:
Code:

root [ / ]# ls /usr/include/c++/7.2.0/stdlib.h
/usr/include/c++/7.2.0/stdlib.h
root [ / ]# ls /usr/include/stdlib.h
/usr/include/stdlib.h


brainAcid 04-21-2020 01:28 PM

LFS 9.1
 
LFS 9.1 same issue
fixed it with

`export CPLUS_INCLUDE_PATH=/usr/include/c++/9.2.0`
then continue buidling :)

found the answer from here
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70129

well i used that and it worked.

mmWwrcgB 09-21-2020 05:28 AM

Quote:

Originally Posted by brainAcid (Post 6114203)
LFS 9.1 same issue
`export CPLUS_INCLUDE_PATH=/usr/include/c++/9.2.0`

Amazing! Thank you.


All times are GMT -5. The time now is 04:40 AM.