LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Linux From Scratch
User Name
Password
Linux From Scratch This Forum is for the discussion of LFS.
LFS is a project that provides you with the steps necessary to build your own custom Linux system.

Notices


Reply
  Search this Thread
Old 12-08-2017, 10:51 AM   #1
vinto
LQ Newbie
 
Registered: Dec 2017
Posts: 2

Rep: Reputation: Disabled
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?
 
Old 12-08-2017, 07:46 PM   #2
sr_ls_boy
Member
 
Registered: Apr 2015
Posts: 105

Rep: Reputation: Disabled
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.
 
Old 12-09-2017, 03:43 AM   #3
vinto
LQ Newbie
 
Registered: Dec 2017
Posts: 2

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by sr_ls_boy View Post
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
 
Old 04-21-2020, 01:28 PM   #4
brainAcid
LQ Newbie
 
Registered: May 2011
Posts: 16

Rep: Reputation: Disabled
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.
 
Old 09-21-2020, 05:28 AM   #5
mmWwrcgB
LQ Newbie
 
Registered: Sep 2020
Posts: 1

Rep: Reputation: Disabled
Smile

Quote:
Originally Posted by brainAcid View Post
LFS 9.1 same issue
`export CPLUS_INCLUDE_PATH=/usr/include/c++/9.2.0`
Amazing! Thank you.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
cmake error "Could not find compiler set in environment variable CC:" sewen67 Linux - Newbie 6 05-10-2014 12:58 AM
gcc compiler cannot find header file stdio.h / stdlib.h debianlam Programming 2 05-11-2008 02:29 PM
gcc compiler cannot find header file stdio.h / stdlib.h debianlam Programming 2 05-09-2008 03:33 PM
BLFS 5.0 dpkg build fails (ncurses-related error) bhaskie Linux From Scratch 2 02-07-2004 04:59 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Linux From Scratch

All times are GMT -5. The time now is 12:47 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration