Conan: Visual Studio Compiler is recognized as C compiler but not as CXX compiler

Created on 27 Sep 2018  路  11Comments  路  Source: conan-io/conan

Windows 7, Conan 1.7.4, Visual Studio 2015

I have an odd issue with my build (specifically, test_package build), where the Visual Studio compiler gets recognized as C compiler, but not as CXX compiler:

CMake log

-- The C compiler identification is MSVC 19.0.24215.1
-- The CXX compiler identification is unknown
-- Check for working C compiler using: Visual Studio 14 2015 Win64
-- Check for working C compiler using: Visual Studio 14 2015 Win64 -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
CMake Error in CMakeLists.txt:
  No CMAKE_CXX_COMPILER could be found.

My profile:

[settings]
os=Windows
os_build=Windows
arch=x86_64
arch_build=x86_64
compiler=Visual Studio
compiler.version=14
compiler.runtime=MD
build_type=Release
[options]
[build_requires]
[env]

CMakeLists.txt

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

add_executable(example  example.cpp)
target_link_libraries(example ${CONAN_LIBS})

To help us debug your issue please explain:

  • [x] I've read the CONTRIBUTING guide.
  • [x] I've specified the Conan version, operating system version and any tool that can be relevant.
  • [x] I've explained the steps to reproduce the error or the motivation/use case of the question/suggestion.
triaging question

Most helpful comment

I hit the same issue ("No CMAKE_CXX_COMPILER could be found"). My Conan recipe worked fine on my local Windows 10 workstation, but it failed when I tried to do exactly the same thing in an Azure pipeline on a Windows 2016 build agent.

Putting "short_paths = True" in my Conan recipe resolved it.

(It's worth noting that the build agent does not have long paths enabled for legacy reasons. Presumably enabling that would have fixed the problem too.)

All 11 comments

You profile is OK.

Looks like CMake does not recognize MSVC as a C++ compiler.
Please check your Visual Studio installation or do some of the checks suggested here https://stackoverflow.com/questions/31619296/cmake-does-not-find-visual-c-compiler

The odd thing here is that the "normal" build works without problems, it is only the test build that has an issue.

Hi @kutschkem

Have you tried adding the project(MyTest CXX) in the CMakeLists.txt of the test_package folder? Please try and tell me, thanks!

This CMakeLists.txt also shows the behavior:

project(PackageTest CXX)
cmake_minimum_required(VERSION 2.8.12)

set (CMAKE_CXX_STANDARD 11)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)

add_executable(example hello.cpp)


target_link_libraries(example CONAN_PKG::eCALMViz)

It's actually a bit strange, because I _think_ it worked before, but I changed something in one of the dependencies and now this package is also showing the symptom.

Conan version is 1.9.1, cmake version is 3.13.0

Also, this here does work, and looks very similar to the original code:

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

add_executable(example example.cpp)
target_link_libraries(example ${CONAN_LIBS})

The only difference I can see is the package this belongs to.

Indeed very weird. Can you reproduce it with a simple "hello world" package that you could share the complete code with us? Is it happening with the conan new Hello/0.1 -s -t + conan create . user/testing code?

Hi @kutschkem

Any news here? Did you manage to reproduce it? Please tell, as we cannot reproduce here, and then there is little we could do. Thanks!

I had a similar problem and could fix it by shortening the path of build folder.

Using lockfile: '__test_package\build\cb9b90f2854f038c4e3be3e555d7c730f95cf6c9/conan.lock'
Using cached profile from lockfile
rs_sys_connector/1.17.0.0@ok/qual (test package): Running build()
-- Selecting Windows SDK version 10.0.10586.0 to target Windows 10.0.17763.
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:3 (PROJECT):
No CMAKE_CXX_COMPILER could be found.

The normal build worked. Just the test package failed with the error above.

Apparently, the CMake compiler detection algorithm run into MAX_PATH related problems. I fixed it by reducing the length of the parent path (by 14 characters).

Using lockfile: '__test_package\build\cb9b90f2854f038c4e3be3e555d7c730f95cf6c9/conan.lock'
Using cached profile from lockfile
rs_sys_connector/1.17.0.0@ok/qual (test package): Running build()
-- Selecting Windows SDK version 10.0.10586.0 to target Windows 10.0.17763.
-- The CXX compiler identification is MSVC 19.0.24218.1
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe -- works

Nothing else was changed.

Maybe this helps here as well?

[I also remember that a virus scanner messed with the CMake compiler detection algorithm once (because some threat heuristic false-positively detected some executables that CMake builded as tests).]

Thanks, I think I might also have been at the limit regarding the path limit, so that may have factored into the problem. I have not reproduced the error since, as I did not do much work on the conan packages.

I hit the same issue ("No CMAKE_CXX_COMPILER could be found"). My Conan recipe worked fine on my local Windows 10 workstation, but it failed when I tried to do exactly the same thing in an Azure pipeline on a Windows 2016 build agent.

Putting "short_paths = True" in my Conan recipe resolved it.

(It's worth noting that the build agent does not have long paths enabled for legacy reasons. Presumably enabling that would have fixed the problem too.)

Was this page helpful?
0 / 5 - 0 ratings