Ubuntu 18.04: No CMAKE_C_COMPILER could be found - gcc

I am trying to install gtest from Google but even though I have gcc and g++ installed, I get this error for some reason. I am on Ubuntu 18.04 64 bit. And I don't have anything to do with Visual Studio stuff.
-- The C compiler identification is unknown
CMake Error at CMakeLists.txt:47 (project):
No CMAKE_C_COMPILER could be found.
Tell CMake where to find the compiler by setting either the environment
variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
the compiler, or to the compiler name if it is in the PATH.
-- Configuring incomplete, errors occurred!
See also "/usr/src/googletest/googletest/CMakeFiles/CMakeOutput.log".
See also "/usr/src/googletest/googletest/CMakeFiles/CMakeError.log".
This is there:
$ gcc --version
gcc (GCC) 6.4.0
$ g++ --version
g++ (GCC) 6.4.0
and this:
user#user:/usr/src/gtest$ whereis g++
g++: /usr/bin/g++ /usr/share/man/man1/g++.1.gz
user#user:/usr/src/gtest$ whereis gcc
gcc: /usr/bin/gcc /usr/lib/gcc /usr/local/cuda-9.0/bin/gcc /usr/share/man/man1/gcc.1.gz
also:
user#user:/usr/src/gtest$ ls -la /usr/bin | grep gcc-6.4
lrwxrwxrwx 1 root root 16 Nov 12 14:47 gcc -> /usr/bin/gcc-6.4
user#user:/usr/src/gtest$ ls -la /usr/bin | grep g++-6
lrwxrwxrwx 1 root root 14 Nov 12 14:51 g++ -> /usr/bin/g++-6
lrwxrwxrwx 1 root root 22 Apr 24 2018 g++-6 -> x86_64-linux-gnu-g++-6
-rwxr-xr-x 1 root root 953176 Apr 24 2018 x86_64-linux-gnu-g++-6
Given all this, does anyone have a clue?
Thanks in advance.
UPDATE: This seems to have worked:
Okay, this seems to be working:
cmake -D CMAKE_C_COMPILER="/usr/local/cuda-9.0/bin/gcc " -D CMAKE_CXX_COMPILER="/usr/bin/g++" /usr/src/gtest/CMakeLists.txt
which apparently points to the gcc used cuda. Is there a way of setting the one under /usr/bin/ as the default one?

Related

Cannot specify a non default C/C++ compiler in CMake under MinGW64 / MSYS

From Mingw-w64, CMake cannot find the non-default compiler I specified on the command line.
This is the pre-build output:
MINGW64 /C/projects/TEST
$ cmake -G "MSYS Makefiles" -D CMAKE_C_COMPILER=/mingw64/bin/gcc -D CMAKE_CXX_COMPILER=/mingw64/bin/g++ ../Test-LineHandler
Sub-project name: Test
-- The C compiler identification is GNU 10.2.0
-- The CXX compiler identification is GNU 10.2.0
CMake Error at CMakeLists.txt:16 (project):
The CMAKE_C_COMPILER:
C:/msys64/mingw64/bin/gcc
is not a full path to an existing compiler tool.
Tell CMake where to find the compiler by setting either the environment
variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
the compiler, or to the compiler name if it is in the PATH.
CMake Error at CMakeLists.txt:16 (project):
The CMAKE_CXX_COMPILER:
C:/msys64/mingw64/bin/g++
is not a full path to an existing compiler tool.
Tell CMake where to find the compiler by setting either the environment
variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
to the compiler, or to the compiler name if it is in the PATH.
-- Configuring incomplete, errors occurred!
See also "C:/projects/TEST/CMakeFiles/CMakeOutput.log".
However, both gcc and g++ exist:
$ ls -l C:/msys64/mingw64/bin/gcc
-rwxr-xr-x 1 RFT RFT 2218766 Dec 10 00:50 C:/msys64/mingw64/bin/gcc
$ ls -l C:/msys64/mingw64/bin/g++
-rwxr-xr-x 1 RFT RFT 2221326 Dec 10 00:50 C:/msys64/mingw64/bin/g++
$ ls -l /mingw64/bin/gcc
-rwxr-xr-x 1 RFT RFT 2218766 Dec 10 00:50 /mingw64/bin/gcc
$ ls -l /mingw64/bin/g++
-rwxr-xr-x 1 RFT RFT 2221326 Dec 10 00:50 /mingw64/bin/g++
This is the generated CMakeOutput.log file:
$ more ./CMakeFiles/CMakeOutput.log
The system is: Windows - 10.0.19041 - AMD64
Compiling the C compiler identification source file "CMakeCCompilerId.c" succeeded.
Compiler: C:/msys64/mingw64/bin/gcc
Build flags:
Id flags:
The output was:
0
Compilation of the C compiler identification source "CMakeCCompilerId.c" produced "a.exe"
The C compiler identification is GNU, found in "C:/projects/TEST/CMakeFiles/3.19.3/CompilerIdC/a.exe"
Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" succeeded.
Compiler: C:/msys64/mingw64/bin/g++
Build flags:
Id flags:
The output was:
0
Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "a.exe"
The CXX compiler identification is GNU, found in "C:/projects/TEST/CMakeFiles/3.19.3/CompilerIdCXX/a.exe"
Am I specifying the non default compiler correctly on the command line?
The exact error is: C:/msys64/mingw64/bin/gcc is not a full path to an existing compiler tool.
Which is correct as the full path is C:/msys64/mingw64/bin/gcc.exe.
So just include the .exe extension of the compiler specified.

c++11 std::unique_ptr error cmake 3.11.3 bootstrap

I am trying to bootstrap cmake 3.11.3 on Ubuntu 16.04.4 LTS xenial.
I have upgrade my gnu g++ compiler as follows:
> $ g++ --version
g++ (Ubuntu 8.1.0-5ubuntu1~16.04) 8.1.0 Copyright (C) 2018 Free
Software Foundation, Inc. This is free software; see the source for
copying conditions. There is NO warranty; not even for MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE.
And manually re-pointed the symbolic links:
$ ll /usr/bin/*g++*
lrwxrwxrwx 1 root root 5 Jun 8 16:57 /usr/bin/g++ -> g++-8*
-rwxr-xr-x 1 root root 919832 Apr 24 15:02 /usr/bin/g++-5*
lrwxrwxrwx 1 root root 22 Jun 6 04:26 /usr/bin/g++-8 -> x86_64-linux-gnu-g++-8*
lrwxrwxrwx 1 root root 22 Jun 8 16:58 /usr/bin/x86_64-linux-gnu-g++ -> x86_64-linux-gnu-g++-8*
lrwxrwxrwx 1 root root 5 Apr 24 15:02 /usr/bin/x86_64-linux-gnu-g++-5 -> g++-5*
-rwxr-xr-x 1 root root 1071984 Jun 6 04:26 /usr/bin/x86_64-linux-gnu-g++-8*
However, I get the following error in the configuration of cmake:
$ sudo ./bootstrap
---------------------------------------------
CMake 3.11.3, Copyright 2000-2018 Kitware, Inc. and Contributors
Found GNU toolchain
C compiler on this system is: gcc
C++ compiler on this system is: g++
Makefile processor on this system is: make
g++ has setenv
g++ has unsetenv
g++ does not have environ in stdlib.h
g++ has stl wstring
g++ has <ext/stdio_filebuf.h>
---------------------------------------------
make: Warning: File 'Makefile' has modification time 2.3 s in the future
make: 'cmake' is up to date.
make: warning: Clock skew detected. Your build may be incomplete.
loading initial cache file /mnt/ganymede/user/gpeytavi/srv_admin/software/cmake-3.11.3/Bootstrap.cmk/InitialCacheFlags.cmake
CMake Error at CMakeLists.txt:92 (message):
The C++ compiler does not support C++11 (e.g. std::unique_ptr).
-- Configuring incomplete, errors occurred!
See also "/mnt/ganymede/user/gpeytavi/srv_admin/software/cmake-3.11.3/CMakeFiles/CMakeOutput.log".
See also "/mnt/ganymede/user/gpeytavi/srv_admin/software/cmake-3.11.3/CMakeFiles/CMakeError.log".
---------------------------------------------
Error when bootstrapping CMake:
Problem while running initial CMake
---------------------------------------------
Any idea why I get a c++11 std::unique_ptr non-compliant error?
In my case, the issue is because of the folder where I have CMake source code is in a mounted directory (in fact my entire rootfs is mounted over NFS)
So, I looked in 'mount' command output and selected '/run/user/1000' location as a local location as this is mounted using tmpfs and moved my CMake source code to this location.
with this, ./bootstrap && make && sudo make install executed successfully.
Actually the ./bootstrap script does try the different C++ standard flags with the compiler. So it should detect its capabilities automatically.
Please make sure you don't have any CXXFLAGS environment variable set and try from scratch again (the messages/warnings you get indicate several tries/errors in the same directory).
Output when Successful
As a reference on my Ubuntu calling CMake's ./bootstrap looks like this:
---------------------------------------------
CMake 3.11.20180423, Copyright 2000-2018 Kitware, Inc. and Contributors
Warning: This is an in-source build
Found GNU toolchain
C compiler on this system is: gcc
C++ compiler on this system is: g++ -std=gnu++1y
Makefile processor on this system is: make
g++ has setenv
g++ has unsetenv
g++ does not have environ in stdlib.h
g++ has stl wstring
g++ has <ext/stdio_filebuf.h>
---------------------------------------------
Debugging
For debugging your problem you also could:
Call ./bootstrap --verbose
Look into Bootstrap.cmk/cmake_bootstrap.log
Known Problem
I only once had a problem with bootstrap using clang compilers where I needed to do the following call:
export CXXFLAGS=-Xclang -std=c++1z -Xclang -stdlib=libc++
Alternative
If you just want to install the latest version see How to specify where CMake is installed in Ubuntu?
I was able to resolve the issue by ensuring that both the build machine and the NFS file server were synchronized by running ntpd on both.
For me it was clock skew. I use the below command :
date -s "2021-11-30 15:08:21"
to set the time to now for the server. Then it work, thanks...

dtruss on OSX 10.9 Mavericks

I'm running OSX Mavericks. As I heard(WWDC 2013, 402-HD.mov) the clang compiler resides now here: -rwxr-xr-x 1 root wheel 29381728 Oct 23 08:40 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
In /usr/bin there's only a wrapper for clang(we can see that from the size):
-rwxr-xr-x 1 root wheel 14224 Oct 22 21:25 /usr/bin/clang
I want to compile one simple C file with clang.
"clang main.c", and I get the a.out (0 errors, 0 warnings). All OK.
Now (the problem) I want to run dtruss on that command line: "sudo dtruss -f clang main.c" but I don't get an a.out. Why? (-f follow children as they are forked). I would have expected that the wrapper does a fork and an exec to the real compiler, but it seems it's not if I run it with dtruss.

lib path on mac osx

I did install the libnfc 1.5.1 in the default directory (/usr/loca/
lib).
if i do an ls i see the libs there:
foo:libnfc-1.5.1 bar$ ls -l /usr/local/lib/libnfc*
-rwxr-xr-x 1 root wheel 62092 Nov 23 09:05 /usr/local/lib/libnfc.2.dylib
-rw-r--r-- 1 root wheel 226696 Nov 23 09:05 /usr/local/lib/libnfc.a
lrwxr-xr-x 1 root wheel 14 Nov 23 09:05 /usr/local/lib/libnfc.dylib ->libnfc.2.dylib
-rwxr-xr-x 1 root wheel 930 Nov 23 09:05 /usr/local/lib/libnfc.la
foo:libnfc-1.5.1 bar$
I did try to run the configure script from mfoc with the following command:
LDFLAGS="-L/usr/local/lib" ./configure
it says that I don't have libnfc >= 1.5.1
checking for LIBNFC... no
configure: error: libnfc >= 1.5.1 is mandatory.
any idea?
This is a guess, but the error looks like it comes from pkg-config. Try:
$ ./configure LDFLAGS=-L/usr/local/lib PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
You really need to look in config.log to see exactly why it cannot find the library.
EDIT: It has often been claimed that pkg-config is fundamentally broken. This case has finally persuaded me that that is indeed true. Setting LDFLAGS should be sufficient, and the fact that it isn't renders this configure script broken. With that in mind, it might be better to disable pkg-config by running configure with the argument PKG_CONFIG=:
Try setting DYLD_LIBRARY_PATH variable and point it to /usr/local/lib before running ./configure:
$ export DYLD_LIBRARY_PATH=/usr/local/lib
$ ./configure

ld can't find X11 library on OSX Leopard

I have a pretty basic X11 app that I run on Linux that I'm trying to get compiled under OSX 10.5.8. I have X11 and the X11 SDK installed, and modified the makefile as follows:
CFLAGS = -L/usr/X11/lib -I/usr/X11/include
Everything compiles fine, but the linker can't find the X11 lib.
ld: library not found for -lX11
I've looked on google, but the only other people I've found with this problem so far either didn't have the X11 SDK installed or didn't know about the -L flag.
Any ideas?
gcc SimpleXlibApp.c -o SimpleXlibApp -lX11 -L/usr/X11/lib -I/usr/X11/include
That line compiles the example here: http://en.wikipedia.org/wiki/Xlib
You may be looking in the wrong location for the library; it's certainly in a different location on my OS X box. Try typing:
locate libX11.dylib
and adding an appropriate path. E.g. on my system you'd need -L/usr/X11/lib/ in you CFLAGS.
-L/usr/X11/lib doesn't work with OSX 10.6 and it has libX11.dylib :
% ls -l /usr/X11/lib/libX11.*
lrwxr-xr-x 1 root wheel 14 Jul 21 17:46 /usr/X11/lib/libX11.6.2.0.dylib# -> libX11.6.dylib
-rwxr-xr-x 1 root wheel 3578368 Jul 12 2010 /usr/X11/lib/libX11.6.dylib*
lrwxr-xr-x 1 root wheel 14 Jul 21 17:46 /usr/X11/lib/libX11.dylib# -> libX11.6.dylib

Resources