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

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.

Related

make: *** makefile. stop

I am new to cmake, and when I compile the makefile using "make -j10" after cmake, it failed and turned out "make: *** makefile. stop." I am really confused. Thanks in advance for precious suggestions!
G:\code\c++\assignment2\code\test>mkdir build
G:\code\c++\assignment2\code\test>cd build
G:\code\c++\assignment2\code\test\build>cmake ..
-- Building for: Visual Studio 16 2019
-- The C compiler identification is MSVC 19.28.29912.0
-- The CXX compiler identification is MSVC 19.28.29912.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: G:/vs/VC/Tools/MSVC/14.28.29910/bin/Hostx64/x64/cl.exe - 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: G:/vs/VC/Tools/MSVC/14.28.29910/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - not found
-- Found Threads: TRUE
-- Found Boost: G:/boost_1_75_0/ (found version "1.75.0") found components: timer chrono
-- Configuring done
-- Generating done
-- Build files have been written to: G:/code/c++/assignment2/code/test/build
G:\code\c++\assignment2\code\test\build>make -j10
make: *** makefile. stop.
Run cmake --build . -j 10 under your build directory.
You didn't build makefiles, you built Visual Studio project files, as can be seen from this line:
Building for: Visual Studio 16 2019
To instruct CMake to generate makefiles instead, use cmake's -G flag:
cmake .. -G "Unix Makefiles"
Or if you didn't intend to build makefiles, you can compile using the generated build system (in this case Visual Studio) as shown in aleck099's answer.

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.

Covert gcc arguments to CMake file

So I am trying to learn CMake and I want to convert the following
gcc "-DARCH=\"`uname -a`\"" cli_arch.c arch.c
to a CMakeLists.txt file.
This is what I got so far:
Running cmake -DCMAKE_C_COMPILER=/usr/bin/gcc "-DARCH=\"`uname -a`\"" ..
// CMakeLists.txt
cmake_minimum_required(VERSION 2.8)
project(cli_arch)
add_executable(cli_arch cli_arch.c arch.c)
The result I am getting is:
-- The C compiler identification is AppleClang 11.0.3.11030032
-- The CXX compiler identification is AppleClang 11.0.3.11030032
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- 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: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
CMake Warning:
Manually-specified variables were not used by the project:
ARCH
I am not understanding how to pass the arguments "-DARCH=\"`uname -a`\"" to CMake.
The trick is execute_process.
execute_process(COMMAND uname -s
OUTPUT_VARIABLE uname_output
OUTPUT_STRIP_TRAILING_WHITESPACE
)
add_executable(cli_arch cli_arch.c arch.c)
target_compile_definitions(cli_arch
PRIVATE "-DARCH=\"${uname_output}\""
)
I had to use uname -s since at least on my system, uname -a has a # which gcc refuses to accept in a macro via the command line.
Edit, since you changed your question. You're passing ARCH to cmake but not doing anything will it. You can pass the argument along using the same target_compile_definitions line I have above.
$ cmake -DARCH2=foo .
$ make
$ ./a
Linux
foo
The relevant part of the new CMakeLists.txt looks like this:
target_compile_definitions(a
PRIVATE "-DARCH=\"${uname_output}\""
PRIVATE "-DARCH2=\"${ARCH2}\""
)

Make command not producing an executable file

I just started using C++ and want to use CMake to compile a simple hello world program, but I don't know what to do with the MakeFile once it is produced. I have a directory called tutorial that contains my tutorial.cpp file containing the hello world code. I also have a CMakeLists file that contains:
cmake_minimum_required(VERSION 3.14.4)
project (tutorial)
add_executable(tutorial tutorial.cpp)
When I run the command cmake . from the tutorial directory in my terminal, all the correct (at least I think they are correct) files are produced and I get the following output:
-- The C compiler identification is AppleClang 10.0.1.10010046
-- The CXX compiler identification is AppleClang 10.0.1.10010046
-- Check for working C compiler:
/Library/Developer/CommandLineTools/usr/bin/cc
-- Check for working C compiler:
/Library/Developer/CommandLineTools/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:
/Library/Developer/CommandLineTools/usr/bin/c++
-- Check for working CXX compiler:
/Library/Developer/CommandLineTools/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to:
/Users/kshitijsachan/Documents/cs/cpp/tutorial
I then typed in make in the terminal and got no output. How can I actually run the makefile that was produced?
Run make <some_valid_target_name> - like make all or make install (if such commonly used targets exist) or whatever other targets your project defined. Check your projects documentation or CMakeLists.txt file for valid target names.
See also cmake_add_executable which adds a target.

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".