How to resolve: Error when bootstrapping CMake on Linux - c++

I received an error while trying to build CMake on Linux. I could not reach the make step. I read around the web but still couldn't really fix this.
I tried both of these, but neither worked:
$ ./configure --prefix=/opt/cmake
$ ./bootstrap
They resulted in:
CMake Error at CmakeLists.txt:107 (message):
The C++ compiler does not support C++11 (e.g. std::unique_ptr).
-- Configuring incomplete, errors occurred
--------------------------------------------
Error when bootstrapping CMake:
Problem while running initial CMake
--------------------------------------------
And:
command -v g++
/usr/bin/g++
g++ --version
g++ (Ubuntu/Linaro 7.4.0-1ubuntu1~18.04.1) 7.4.0
The code I am trying to compile is in C, so I'm wondering why I'm receiving errors raised with respect to the C++ Compiler? Perhaps any thoughts on this too?

You can set up the specific gcc and g++ version using the following commands.
export CC=path_of_gcc/gcc-version
export CXX=path_of_g++/g++-version
And now run any of the commands:
./configure #OR
./bootstrap

Related

How to enable later versions of GCC in eclipse CDT in CentOS 7

My CentOS 7 machine has a default GCC version of 4.8.5. I want to use a higher version of GCC. So, I executed the following steps in a terminal:
sudo yum install centos-release-scl
sudo yum install devtoolset-10-gcc*
scl enable devtoolset-10 bash
After performing the steps, my GCC is now 10.2.1. I then launched Eclipse CDT (10.2.0) through the terminal. Upon enabling C++20 in Eclipse, I tried to compile a simple "hello world" code, but I received the following error in the Eclipse console:
g++ -std=c++2a -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/dummy2.d" -MT"src/dummy2.o" -o "src/dummy2.o" "../src/dummy2.cpp"
g++: error: unrecognized command line option ‘-std=c++2a’
make: *** [src/dummy2.o] Error 1
"make all" terminated with exit code 2. Build might be incomplete.
My system PATH variable has the following directory as its first entry: /opt/rh/devtoolset-10/root/usr/bin. So, I don't know why my Eclipse is still using the old GCC 4.8.5. How do I adjust my Eclipse settings so that I am able to compile higher versions of C++ in CentOS 7?

Compilation errors with M1 MacBook Pro and cmake

I have just got my new M1 MacBook Pro and am trying to compile a code base required for my university work. Here are the steps I have taken:
I set Terminal to always open using Rosetta.
Installed homebrew using /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Installed cmake using brew install cmake
Run cmake <path to source> (this works fine)
Run make (this fails)
Here is the error I get:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/stdlib.h:97:15: fatal error:
'stdlib.h' file not found
#include_next <stdlib.h>
I have tried uninstalling and re-installing Xcode and CommandLineTools to no avail.
When using the cmake gui app, I get a different error. I have it set to use CommandLineTools/SDKs/MacOsX11.0.sdk.
When running make after generating and configuring the build files using this cmake gui setup, I get this error:
-- The C compiler identification is AppleClang 12.0.0.12000032
-- The CXX compiler identification is AppleClang 12.0.0.12000032
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - broken
CMake Error at /Applications/CMake.app/Contents/share/cmake-3.18/Modules/CMakeTestCCompiler.cmake:66 (message):
The C compiler
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /Users/freyamurphy/nori/build/ext_build/src/tbb_p-build/CMakeFiles/CMakeTmp
If I run the command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc test.c (Simple hello world program) I get this error:
test.c:1:10: fatal error: 'stdio.h' file not found
#include "stdio.h"
But using cc test.c everything works fine. (This runs usr/bin/cc).
Seems to me there is perhaps an issue with Xcode. Has anyone had any similar issues or could give me some advice? It would be much appreciated.
Have you reopen Terminal after xcode installed? It's needed to set the environment variable SDKROOT.
Close and run again Terminal or open a new tab in Terminal.
Or run the following command in the current Terminal
export SDKROOT=$(xcrun --sdk macosx --show-sdk-path)
Also be sure the proper xcode toolchain is selected
# list available xcode toolchains
xcode-select -p
# select one of listed above
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer

CMake can not find g++ compiler on Windows

I have a CMake project I want to compile with g++. The project compiles and runs on Linux. Now I am trying to get it working on Windows.
For that reason, I installed MinGW and added it to the PATH and I am using Git Bash. In order to force CMake to use g++ I added these env variables:
CC = C:\MinGW\bin\gcc
CXX = C:\MinGW\bin\g++
But when I run CMake it does not detect any compilers and tells me:
-- The C compiler identification is unkown
-- The CXX compiler identification is unkown
I created a super basic example on github which I would like to get running on Windows + MinGw: https://github.com/j-o-d-o/Basic-CMake-Project
How can I use the env variables in windows to force CMake to use g++ and gcc compiler?
I needed to add -G "MinGW Makefiles" to the CMake command.
I check if I am on Windows and if yes, I add the parameter to the CMake command in the shell script.
I also need to use mingw32-make instead of make when I am on Windows.
There are some other issues now, but it resolves the issue/question I have posted.

clang compile failed on mariadb

system is CentOS(VirtualBox) x64
I had "yum install" and "yum check" cmake clang gcc libstdc++ and compat-libstdc++*
I had link cmake to clang
I had compile a "HelloWorld" program by clang successed
then,
I try to compile mariadb'code use : "cmake . -DBUILD_CONFIG=mysql_release".
I got error like this:
...
CMake Error at /usr/share/cmake/Modules/CMakeTestCXXCompiler.cmake:54 (message):
The C++ compiler "/usr/bin/clang++" is not able to compile a simple test
program.
...
/usr/bin/ld: cannot find -lstdc++
...
How can I fix this problem? Thanks very much!
(Please forgive me for my poor English T_T)
Getting libstdc++-devel, etc. etc. c++ : # yum install gcc-c++

luarocks 'gcc-plugin.h' build error

I am trying to use torch together with the hdf5 package. I am trying to install it via luarocks install hdf5 but during the build phase I get an error regarding the gcc-plugin header. (gcc relies on clang backend). The complete error message is:
luarocks install --local hdf5
Installing https://luarocks.org/hdf5-2.0.0-1.src.rock...
Using https://luarocks.org/hdf5-2.0.0-1.src.rock... switching to 'build' mode
Warning: variable CFLAGS was not passed in build_variables
gcclua-config.h:1:10: fatal error: 'gcc-plugin.h' file not found
#include "gcc-plugin.h"
^
1 error generated.
env MACOSX_DEPLOYMENT_TARGET=10.8 gcc -c -o gcclua.o -Iplugin/include -fPIC -O2 -Wall -Wformat-security -I/usr/local/Cellar/lua/5.2.4_3/include gcclua.c
gcclua.c:7:10: fatal error: 'gcc-plugin.h' file not found
#include "gcc-plugin.h"
^
1 error generated.
make[2]: *** [gcclua.o] Error 1
make[1]: *** [gcc] Error 2
make: *** [gcc-lua] Error 2
Just to give more information, I am relying on
gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
xcrun: error: couldn't stat toolchain: '/Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.11.xctoolchain' (errno=No such file or directory)
Apple LLVM version 7.3.0 (clang-703.0.29)
Target: x86_64-apple-darwin15.0.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
Does anybody has maybe a hint how to fix this issue?
Every help is greatly appreciated!!!
In addition to gcc, you need the headers, which on Linux you can get with sudo apt-get install gcc-4.8-plugin-dev. If you're on a different OS or version of gcc, just substitute the appropriate package manager / gcc version number.
gcc-plugin.h is a part of GCC, so I think you'll really need to install gcc to get that. Clang provides a gcc-compatible front-end script but that merely presents a command-line driver with compatible flags.
You should be able to install GCC using Homebrew: https://apple.stackexchange.com/a/86588
I bet you tried to work on a CS287-16 class :). I have contacted the developer of this library who wasn't that easy to do something to solve the problem. Apparently he has no friends who have a Mac PC... As a workaround I could suggest you to use a Docker container with Linux in it to run Lua scripts. That's what I have ended up with...
Here's the Docker image I was talking about: https://github.com/aoboturov/cs287-16-lua. You could build it yourself and the just run as a Docker container :)