Switching back to Clang compiler for mac terminal - c++

When compiling my code, in terminal I used to see:
>-- The CXX compiler identification is AppleClang 12.0.0.12000032
> -- Detecting CXX compiler ABI info
> -- Detecting CXX compiler ABI info - done
> -- Check for working CXX compiler: >/Library/Developer/CommandLineTools/usr/bin/c++ - skipped
> -- Detecting CXX compile features
> -- Detecting CXX compile features - done
For unrelated reasons, I wanted the compiler to be GCC instead of Apple Clang. So in terminal, I set
CC=/usr/local/Cellar/gcc/11.1.0_1/bin/gcc-11
and
CXX=/usr/local/Cellar/gcc/11.1.0_1/bin/g++-11
in an attempt to switch from clang to gcc as the compiler used in terminal. But I would get the following error message:
> -- The CXX compiler identification is unknown
> -- Detecting CXX compiler ABI info
> -- Detecting CXX compiler ABI info - failed
> -- Check for working CXX compiler: /usr/bin/c++
> -- Check for working CXX compiler: /usr/bin/c++ - broken
> CMake Error at /usr/local/Cellar/cmake/3.20.5/share/cmake/Modules/CMakeTestCXXCompiler.cmake:59 (message):
>The C++ compiler
>/usr/bin/c++
>is not able to compile a simple test program.
Now I want to switch back to clang and tried setting
CC=/usr/bin/clang
and
CXX=/usr/bin/clang++
in terminal, but I now get the same error message as above where the compiler is unknown.

Related

Can't get CLion to actually use GCC compiler instead of Clang?

I've tried following all the help to change my compiler to use GCC instead of Clang (on macOS) as I would like to try to use __gnu_pbds::priority_queue instead of the STL version, and it still appears that CMake uses Clang. I've made a toolchain that looks like this:
and set it to be used in the CMake profile.
However, it appears CMake skips actually using the compiler - here is the CMake output:
/Applications/CLion.app/Contents/bin/cmake/mac/bin/cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=/usr/bin/gcc -DCMAKE_CXX_COMPILER=/usr/bin/g++ -G "CodeBlocks - Unix Makefiles" -S /Users/steve/CLionProjects/TestModernTimeStretch -B /Users/steve/CLionProjects/TestModernTimeStretch/cmake-build-release-gcc
-- The C compiler identification is AppleClang 13.1.6.13160021
-- The CXX compiler identification is AppleClang 13.1.6.13160021
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for stdbool.h
-- Looking for stdbool.h - found
-- Looking for unistd.h
-- Looking for unistd.h - found
-- Checking processor clipping capabilities...
-- Performing Test CPU_CLIPS_POSITIVE
-- Performing Test CPU_CLIPS_POSITIVE - Failed
-- Performing Test CPU_CLIPS_NEGATIVE
-- Performing Test CPU_CLIPS_NEGATIVE - Failed
-- Checking processor clipping capabilities... none
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/steve/CLionProjects/TestModernTimeStretch/cmake-build-release-gcc

Cmake Error Compiling Hydrogen 0.9.7 Beta1

I am attempting to compile Hydrogen 0.9.7 beta 2 with Cmake and I keep getting a cmakelists.txt error: CMake Error at CMakeLists.txt:139 (MANDATORY_PKG):
Unknown CMake command "MANDATORY_PKG"
Reviewing the list of Cmake commands I cant find a command that corresponds to MANDATORY_PKG. Is this deprecated language?
Here is the output of the attempted build.
tinman13#tinman13-scythion:~/hydrogen-1.0.0-beta1/build$ sudo cmake /home/tinman13 /hydrogen-1.0.0-beta1/build
-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
fatal: not a git repository (or any of the parent directories): .git
CMake Error at CMakeLists.txt:138 (INCLUDE):
INCLUDE could not find load file:
StatusSupportOptions
CMake Error at CMakeLists.txt:139 (MANDATORY_PKG):
Unknown CMake command "MANDATORY_PKG".
-- Configuring incomplete, errors occurred!
See also "/home/tinman13/hydrogen-1.0.0-beta1/build/CMakeFiles/CMakeOutput.log".
CMakeOutput.log is a large rambling file but i'll post it if you like.
Is there anything that can be done to rectify this? Can i switch to an older version of CMake? Googling produces very little on the topic of unknown CMake commands and nothing related to Hydrogen. Any help would be greatly appreciated.

CMake with mingw on Windows 10: Detecting CXX compiler ABI info - failed

I want to use cmake to create MinGW Makefiles on windows 10. I have installed mingw and I can use mingw32-make and g++ commands without issue.
The test project is a super simple CMakeLists.txt file:
cmake_minimum_required(VERSION 3.10)
project(hello-world)
add_executable(hello-world main.cpp)
and a simple main.cpp file:
#include <iostream>
int main() {
std::cout << "hello Visual Studio Code! :)" << '\n';
return 0;
}
These are the commands I use to create the makefiles:
>> mkdir build
>> cd build
>> cmake -G "MinGW Makefiles" ..
This is where I get errors:
CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.10/Modules/CMakeDetermineCompilerId.cmake:495 (file):
file STRINGS file
"C:/Projects/test/build/CMakeFiles/3.10.1/CompilerIdCXX/a.exe" cannot be read.
... some more errors in the test files
-- The CXX compiler identification is GNU 6.3.0
-- Check for working C compiler: C:/MinGW/bin/gcc.exe
-- Check for working C compiler: C:/MinGW/bin/gcc.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/MinGW/bin/g++.exe
-- Check for working CXX compiler: C:/MinGW/bin/g++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring incomplete, errors occurred!
This is from the error log:
The CXX compiler identification could not be found in "C:/Projects/test/build/CMakeFiles/3.10.1/CompilerIdCXX/a.exe"
What is the CXX compiler ABI info and how can it be, that there is a working CXX compiler detected but this fails?
Let me know if you need anymore info about the setup!
What turned out to be my culprit was Windows Defender! Turned that off and the CXX compiler ABI info - failed issue went away.
I used the CMake-GUI tool to figure out the missing tool dependencies. For example : CMAKE_ADDR2LINE was not set, once I pointed it to the correct location of addr2line.exe ,the errors were resolved.

Cmake doesn't see variable from find_path

I am trying to compile code with activemq-cpp with cmake and gcc 5.4
find_path(ACTIVEMQCPP_DIR NAMES cms/Config.h HINTS $ENV{ACTIVEMQDIR})
Here ACTIVEMQDIR is an environment variable set to
/usr/local/include/activemq-cpp-3.10.0
message(STATUS ACTIVEMQCPP_DIR=${ACTIVEMQCPP_DIR})
include_directories(${ACTIVEMQCPP_DIR})
//include_directories(/usr/local/include/activemq-cpp-3.10.0)
If i hardcode path explicitly, then it is ok...
Output from cmake:
-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- 1=/usr/local/include/activemq-cpp-3.10.0
-- 2=/usr/local/lib
-- 3=/usr/local/include/activemq-cpp-3.10.0
-- 4=/usr/local/lib/libactivemq-cpp.so
-- Configuring done
-- Generating done
-- Build files have been written to
-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
ACTIVEMQCPP_DIR=/usr/local/include/activemq-cpp-3.10.0
-- Configuring done
-- Generating done
-- Build files have been written to: /home/oem/ClionProjects/untitled/b2
The problem is that include_directories(${ACTIVEMQCPP_DIR}) doesn't work. Variable ACTIVEMQCPP_DIR is not set
Write it like this
include_directories($ENV{ACTIVEMQCPP_DIR})
so that cmake knows it's an environemnt variable.

Plugin refuses to compile due to COMPILER_SUPPORTS_CXX11 test failing

This is the following output i keep getting when i run the commands
I'm not sure exactly where im going wrong here. I'm also having issues with boost yum says the boost libraries installed.
cmake teamspeak-connector
-- The C compiler identification is GNU 4.8.2
-- The CXX compiler identification is GNU 4.8.2
-- Check for working C compiler: /opt/rh/devtoolset-2/root/usr/bin/gcc
-- Check for working C compiler: /opt/rh/devtoolset-2/root/usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /opt/rh/devtoolset-2/root/usr/bin/c++
-- Check for working CXX compiler: /opt/rh/devtoolset-2/root/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Performing Test COMPILER_SUPPORTS_CXX11
-- Performing Test COMPILER_SUPPORTS_CXX11 - Failed
CMake Error at CMakeLists.txt:73 (message):
The compiler /opt/rh/devtoolset-2/root/usr/bin/c++ does not fulfill all
required standards. Please use a different C++ compiler.
-- Configuring incomplete, errors occurred!
See also "/root/sampcompiles/samp-tsconnector-1.2.1/CMakeFiles/CMakeOutput.log".
See also "/root/sampcompiles/samp-tsconnector-1.2.1/CMakeFiles/CMakeError.log".