0

In Windows 11 I have no compiler, no Ninja.

I have already installed Conan and Cmake 3.27.7

pip install conan
pip install cmake

I want to repeat a very simple example but I make it even simpler; main.c:

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int main(void) {
    printf("Hello world");
    return EXIT_SUCCESS;
}

conanfile.txt:

[requires]
ninja/1.11.1
mingw-builds/12.2.0

[tool_requires]
cmake/3.22.6

[generators]
CMakeDeps
CMakeToolchain

My steps:

examples2\tutorial\consuming_packages\tool_requires> conan install . --output-folder=build --build=missing

Log:

======== Input profiles ======== Profile host: [settings] arch=x86_64 build_type=Release os=Windows

Profile build: [settings] arch=x86_64 build_type=Release os=Windows

======== Computing dependency graph ======== Graph root conanfile.txt: C:\Users\Dunge\OneDrive\Documents\GitHub\examples2\tutorial\consuming_packages\tool_requires\conanfile.txt Requirements mingw-builds/12.2.0#6d4f9fa696c4097c55762e2f481a2355 - Cache ninja/1.11.1#77587f8c8318662ac8e5a7867eb4be21 - Cache Build requirements 7zip/19.00#225017a375b8ed37d07d6623e85d9332 - Cache cmake/3.22.6#32cced101c6df0fab43e8d00bd2483eb - Cache lzma_sdk/9.20#f1fe20056422603432563a07b25f2ee3 - Cache make/4.3#f3747ef6e47bbd049f9f3f14a9e1d8ba - Cache msys2/cci.latest#567331f1604f3c584f04feade960f06e - Cache

======== Computing necessary packages ======== Requirements mingw-builds/12.2.0#6d4f9fa696c4097c55762e2f481a2355:f4943bfd33cc2961ebbb1d81bf8b090153522e1f#5f5a8fabb19ee4c50cd60cea4f4d5237

  • Cache ninja/1.11.1#77587f8c8318662ac8e5a7867eb4be21:723257509aee8a72faf021920c2874abc738e029#74ebd8f35f54015dcbf2b18a6adbd023
  • Cache Build requirements cmake/3.22.6#32cced101c6df0fab43e8d00bd2483eb:522dcea5982a3f8a5b624c16477e47195da2f84f#a9d024f459972755e5a815b775408fff
  • Cache Skipped binaries 7zip/19.00, lzma_sdk/9.20, make/4.3, msys2/cci.latest

======== Installing packages ======== cmake/3.22.6: Already installed! (1 of 3) cmake/3.22.6: Appending PATH environment variable: C:\Users\Dunge.conan2\p\cmake1927748c2604b\p\bin ninja/1.11.1: Already installed! (2 of 3) mingw-builds/12.2.0: Already installed! (3 of 3) WARN: deprecated: Usage of deprecated Conan 1.X features that will be removed in Conan 2.X: WARN: deprecated: 'env_info' used in: cmake/3.22.6, mingw-builds/12.2.0

======== Finalizing install (deploy, generators) ======== conanfile.txt: Writing generators to C:\Users\Dunge\OneDrive\Documents\GitHub\examples2\tutorial\consuming_packages\tool_requires\build conanfile.txt: Generator 'CMakeDeps' calling 'generate()' conanfile.txt: Generator 'CMakeToolchain' calling 'generate()' conanfile.txt: CMakeToolchain generated: conan_toolchain.cmake conanfile.txt: Preset 'conan-release' added to CMakePresets.json. Invoke it manually using 'cmake --preset conan-release' if using CMake>=3.23 conanfile.txt: If your CMake version is not compatible with CMakePresets (<3.23) call cmake like: 'cmake -G "MinGW Makefiles" -DCMAKE_TOOLCHAIN_FILE=C:\Users\Dunge\OneDrive\Documents\GitHub\examples2\tutorial\consuming_packages\tool_requires\build\conan_toolchain.cmake -DCMAKE_SH=CMAKE_SH-NOTFOUND -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_BUILD_TYPE=Release' conanfile.txt: CMakeToolchain generated: CMakePresets.json conanfile.txt: CMakeToolchain generated: ..\CMakeUserPresets.json conanfile.txt: Generating aggregated env files conanfile.txt: Generated aggregated env files: ['conanbuild.bat', 'conanrun.bat'] Install finished successfully

examples2\tutorial\consuming_packages\tool_requires> cd build
examples2\tutorial\consuming_packages\tool_requires> ./conanbuild.bat
examples2\tutorial\consuming_packages\tool_requires> cmake -S .. -B . -G "Ninja" -DCMAKE_TOOLCHAIN_FILE='conan_toolchain.cmake' --fresh

Log

-- Using Conan toolchain: C:/Users/Dunge/OneDrive/Documents/GitHub/examples2/tutorial/consuming_packages/tool_requires/build/conan_toolchain.cmake -- The C compiler identification is unknown CMake Error at CMakeLists.txt:2 (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!

Why can't Conan install MinGW with Ninja by himself and use it by himself?

1 Answer 1

1

It might be that ninja and mingw should be tool_requires rather than requires. I just tried this (on Windows 10) and it worked for me (and used the correct compiler: MINGW 12.2.0).

mainfile.c:

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int main(void) {
    printf("Hello world");
    return EXIT_SUCCESS;
}

CMakeLists.txt:


cmake_minimum_required(VERSION 3.15.3)

project(simple)
enable_language(C)

set(C_SOURCE_FILES
    mainfile.c
    )

set(EXECUTABLE ${PROJECT_NAME})
add_executable(${EXECUTABLE} ${C_SOURCE_FILES} )

conanfile.txt

[requires]

[tool_requires]
cmake/3.22.6
mingw-builds/12.2.0
ninja/1.11.1

[generators]
CMakeDeps
CMakeToolchain

Commands run at the shell

python -m pip install conan

# This found MSVC on my system, but it isn't used later:
conan profile detect --force

conan install . --output-folder=build --build=missing

cd build

.\conanbuild.bat

cmake -G Ninja ..

cmake --build .

.\simple.exe
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.