Ошибка cmake error at the c compiler

I am trying to run CMake on Windows, and I get the following error:

-- The C compiler identification is unknown
CMake Error at CMakeLists.txt:3 (PROJECT):
  The CMAKE_C_COMPILER:

    cl

  is not a full path and was not found in the PATH.

  To use the NMake generator with Visual C++, cmake must be run from a shell
  that can use the compiler cl from the command line.  This environment is
  unable to invoke the cl compiler.  To fix this problem, run cmake from the
  Visual Studio Command Prompt (vcvarsall.bat).

  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.

However my «CC» environment variable is set!

>>echo %CC%
C:Anaconda2MinGWx86_64-w64-mingw32bingcc.exe

Peter Mortensen's user avatar

asked Mar 8, 2016 at 14:07

João Abrantes's user avatar

João AbrantesJoão Abrantes

4,7634 gold badges35 silver badges70 bronze badges

5

Because CMake’s error message is misleading here, I think it warrants a little more detailed answer.

In short, you ran into a chicken-and-egg kind of a problem.

CMake’s compiler detection is mighty, but since — during the first try —

  • you didn’t give any explicit generator to use with -G
  • it couldn’t find a Visual Studio installed
  • it couldn’t find any C/C++ compiler in your PATH environment
  • it couldn’t find a CC environment variable defined with the full path to a compiler

It was defaulting to nmake.

Now here comes the problem: it does remember your implicit generator/compiler choice in it’s variable cache (see CMAKE_GENERATOR in CMakeCache.txt). What is a very useful feature, if you have multiple compilers installed.

But if you then declare the CC environment variable — as the error message suggests — it’s too late since your generator’s choice was remembered in the first try.

I see two possible ways out of this:

  1. Overrule the generator choice by given the right one with cmake.exe -G "MinGW Makefiles" .. (as the answer linked by @Guillaume suggests)
  2. Delete your project’s binary output directory (including CMakeCache.txt) and do cmake.exe .. after you added your compiler’s bin folder to your PATH environment.

References

  • Running CMake on Windows
  • What is the default generator for CMake in Windows?
  • CMake error at CMakeLists.txt:30 (project): No CMAKE_C_COMPILER could be found
  • CMake: how to specify the version of Visual C++ to work with?

starball's user avatar

starball

15.1k6 gold badges28 silver badges134 bronze badges

answered Mar 11, 2016 at 8:02

Florian's user avatar

1

I use cmake -G "MinGW Makefiles" . instead of cmake .
It worked!

answered Jun 17, 2021 at 8:49

Lucky Ning's user avatar

I came across the same problem and what worked for me was:

  1. I installed Visual Studio (following this tutorial ).
  • You will need to install the 2019 version (it is 2021 now) — there are a few extra things but it’s fine. The entire thing is about 6.7 G.
  • You don’t really need the pip install dlib part and the rest.
  1. On the basis of the above tutorial, I added this path to the environment variable (
    C:Program Files (x86)Microsoft Visual Studio2019BuildToolsVCToolsMSVC14.29.30037binHostx64x64. The method of adding paths to the environment variable can also be found in the above tutorial.)

answered May 28, 2021 at 14:08

SuperDuperMario's user avatar

CMake Discourse

Loading

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement. We’ll occasionally send you account related emails.

Already on GitHub?
Sign in
to your account

Closed

HillalRoy opened this issue

Oct 18, 2020

· 17 comments

Comments

@HillalRoy

Description

I also try to create new project with android native c++ template but the output is same
The Build output

E:devAndroidSOUNICappCMakeLists.txt : C/C++ debug|arm64-v8a : CMake Error at C:/Users/Hillal/AppData/Local/Android/Sdk/cmake/3.10.2.4988404/share/cmake-3.10/Modules/CMakeTestCCompiler.cmake:52 (message):
  The C compiler

    "C:/Users/Hillal/AppData/Local/Android/Sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: E:/dev/Android/SOUNIC/app/.cxx/cmake/debug/arm64-v8a/CMakeFiles/CMakeTmp
    
    Run Build Command:"C:UsersHillalAppDataLocalAndroidSdkcmake3.10.2.4988404binninja.exe" "cmTC_0bd68"
    [1/2] Building C object CMakeFiles/cmTC_0bd68.dir/testCCompiler.c.o
    [2/2] Linking C executable cmTC_0bd68
    FAILED: cmTC_0bd68 
    cmd.exe /C "cd . && C:UsersHillalAppDataLocalAndroidSdkndk21.3.6528147toolchainsllvmprebuiltwindows-x86_64binclang.exe --target=aarch64-none-linux-android23 --gcc-toolchain=C:/Users/Hillal/AppData/Local/Android/Sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/windows-x86_64 --sysroot=C:/Users/Hillal/AppData/Local/Android/Sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/windows-x86_64/sysroot -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -D__STDC_FORMAT_MACROS  -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libgcc_real.a -Wl,--exclude-libs,libatomic.a -static-libstdc++ -Wl,--build-id -Wl,--fatal-warnings -Wl,--no-undefined -Qunused-arguments -Wl,--gc-sections CMakeFiles/cmTC_0bd68.dir/testCCompiler.c.o  -o cmTC_0bd68  -latomic -lm && cd ."
    The system cannot find the path specified.
    ninja: build stopped: subcommand failed.
    

  

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt

Environment Details

  • Android StudioVersion: 4.1
  • NDK Version: 21.3.6528147
  • Build system: CMake c++17
  • Host OS: Windows 10
  • ABI: ‘x86’, ‘x86_64’, ‘armeabi-v7a’, ‘arm64-v8a’

@HillalRoy
HillalRoy

changed the title
[BUG] Is not able to compile a simple test program.

[BUG] It is not able to compile a simple test program.

Oct 18, 2020

@DanAlbert

Not enough information. We have tests that show that Clang and CMake work just fine. Nothing we can do without a repro case. Provide one and we’ll reopen.

@hujianglang

@DanAlbert

Until we know what the problem is we don’t know. Do you have a repro case you can upload?

@HillalRoy

Sorry the problem was mine pc env.

I had a auto run script that script was deleted but forget to remove from auto run.

If you have same problem the goto the registry of command prompt and check auto run.

@hchanon

To add details following HillalRoy comments, I hit the same problem and
fixed it by removing the AutoRun entry from «ComputerHKEY_CURRENT_USERSoftwareMicrosoftCommand Processor» on my Windows machine.
The Autorun key was calling Conda. (from some Python tooling)
I did not investigate the mechanism that interfered with the CMake build.

@pnemonic78

Try use latest NDK, e.g. 22.0.7026061

@dhirajnitk

 FAILED: cmTC_1f121 
    cmd.exe /C "cd . && E:Androidndk22.0.7026061toolchainsllvmprebuiltwindows-x86_64binclang.exe --target=armv7-none-linux-androideabi27 --gcc-toolchain=E:/Android/ndk/22.0.7026061/toolchains/llvm/prebuilt/windows-x86_64 --sysroot=E:/Android/ndk/22.0.7026061/toolchains/llvm/prebuilt/windows-x86_64/sysroot -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -march=armv7-a -mthumb -Wformat -Werror=format-security -O2  -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libgcc_real.a -Wl,--exclude-libs,libatomic.a -Wl,--build-id=sha1 -Wl,--no-rosegment -Wl,--fatal-warnings -Wl,--exclude-libs,libunwind.a -Wl,--no-undefined -Qunused-arguments -Wl,--gc-sections CMakeFiles/cmTC_1f121.dir/testCCompiler.c.o  -o cmTC_1f121  -latomic -lm && cd ."

clang: error: unable to execute command: program not executable
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

@DanAlbert

Same as before. We can’t help without a repro case.

@dhirajnitk

I can’t build anything until I put this on top
SET (CMAKE_C_COMPILER_WORKS 1)
SET (CMAKE_CXX_COMPILER_WORKS 1)

Now I am getting linking error without any reasons for native .so files although it is building Cpp files successfully.
The app was building fine before on windows Android studio

@DanAlbert

Can you upload a repro case?

@dhirajnitk

I certainly feel its mixture of environment and ndk problem. I am facing this issue on 22.0.7026061, but if I migrate to 18.1.5063045, the issue disappears. Few days ago it was working fine on 22.0.7026061when I had been developing native project with NDK 22.0.7026061 for over a month.

I saw the cmd output & I dont see any corruption with conda[This is something I had faced once with clion in past] I have also commented the local ninja installation from path environment.
IF I put

SET (CMAKE_C_COMPILER_WORKS 1)
SET (CMAKE_CXX_COMPILER_WORKS 1)

The c++ code is built but .so files linking still fails as its shown in the sample test program.
There is something wrong with clang

C/C++ debug|arm64-v8a : CMake Error at E:/Android/cmake/3.10.2.4988404/share/cmake-3.10/Modules/CMakeTestCCompiler.cmake:52 (message):
The C compiler

"E:/Android/ndk/22.0.7026061/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe"

is not able to compile a simple test program.

It fails with the following output:

Change Dir: D:/Users/xxxx/Helloworld_android/app/.cxx/cmake/debug/arm64-v8a/CMakeFiles/CMakeTmp

Run Build Command:"E:Androidcmake3.10.2.4988404binninja.exe" "cmTC_8b765"
[1/2] Building C object CMakeFiles/cmTC_8b765.dir/testCCompiler.c.o
[2/2] Linking C executable cmTC_8b765
FAILED: cmTC_8b765
cmd.exe /C "cd . && E:Androidndk22.0.7026061toolchainsllvmprebuiltwindows-x86_64binclang.exe --target=aarch64-none-linux-android27 --gcc-toolchain=E:/Android/ndk/22.0.7026061/toolchains/llvm/prebuilt/windows-x86_64 --sysroot=E:/Android/ndk/22.0.7026061/toolchains/llvm/prebuilt/windows-x86_64/sysroot -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -O2  -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libgcc_real.a -Wl,--exclude-libs,libatomic.a -Wl,--build-id=sha1 -Wl,--no-rosegment -Wl,--fatal-warnings -Wl,--no-undefined -Qunused-arguments -Wl,--gc-sections CMakeFiles/cmTC_8b765.dir/testCCompiler.c.o  -o cmTC_8b765  -latomic -lm && cd ."
clang: error: unable to execute command: program not executable
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:8 (project)

D:UsersxxxxHelloworld_androidappsrcmaincppCMakeLists.txt : C/C++ debug|arm64-v8a : Configuration failed.
executing external native build for cmake D:UsersxxxxHelloworld_androidappsrcmaincppCMakeLists.txt

It says clang: error: unable to execute command: program not executable during linking.

@dhirajnitk

D:ndk-sampleshello-jniappsrcmaincppCMakeLists.txt : C/C++ arm8Debug|armeabi-v7a : CMake Error at E:/Android/cmake/3.10.2.4988404/share/cmake-3.10/Modules/CMakeTestCCompiler.cmake:52 (message):
The C compiler

"E:/Android/ndk/22.0.7026061/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe"

is not able to compile a simple test program.

It fails with the following output:

Change Dir: D:/ndk-samples/hello-jni/app/.cxx/cmake/arm8Debug/armeabi-v7a/CMakeFiles/CMakeTmp

Run Build Command:"E:Androidcmake3.10.2.4988404binninja.exe" "cmTC_f1d4a"
[1/2] Building C object CMakeFiles/cmTC_f1d4a.dir/testCCompiler.c.o
[2/2] Linking C executable cmTC_f1d4a
FAILED: cmTC_f1d4a 
cmd.exe /C "cd . && E:Androidndk22.0.7026061toolchainsllvmprebuiltwindows-x86_64binclang.exe --target=armv7-none-linux-androideabi27 --gcc-toolchain=E:/Android/ndk/22.0.7026061/toolchains/llvm/prebuilt/windows-x86_64 --sysroot=E:/Android/ndk/22.0.7026061/toolchains/llvm/prebuilt/windows-x86_64/sysroot -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -march=armv7-a -mthumb -Wformat -Werror=format-security  -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libgcc_real.a -Wl,--exclude-libs,libatomic.a -static-libstdc++ -Wl,--build-id=sha1 -Wl,--no-rosegment -Wl,--fatal-warnings -Wl,--exclude-libs,libunwind.a -Wl,--no-undefined -Qunused-arguments -Wl,--gc-sections CMakeFiles/cmTC_f1d4a.dir/testCCompiler.c.o  -o cmTC_f1d4a  -latomic -lm && cd ."
clang: error: unable to execute command: program not executable
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt

Unable to build hello-jni from ndk_samples.

Note: I reinstalled ndk 22.0.7026061. Library was built & it ran on emulator. But once I rebuild project, its back to same linking error.

@DanAlbert

clang: error: unable to execute command: program not executable

Sounds like a permissions issue. Either the install went wrong or maybe your antivirus is getting in the way. This isn’t something we’ve encountered so I’m fairly confident it isn’t a problem with the package itself.

Guessing at a question you might be asking yourself: «But how could that be true if it did work once?» Presumably the not-full-rebuild didn’t run whichever program is broken, which is why only the rebuild broke.

@dhirajnitk

It works on 18.1.5063045 so there is something peculiar with android studio & ndk 22.xxxxxxx

@DanAlbert

You probably need to file a Studio bug. If it’s not something wrong with the NDK package itself we aren’t the ones that can fix it. Given that everything works fine for me when I extract the package myself I don’t think it’s an issue with the package. If you have reason to believe otherwise, please file a new bug with that data.

@kirkaDev

It works on 18.1.5063045 so there is something peculiar with android studio & ndk 22.xxxxxxx

I had the same issue with ndkVersion «23.1.7779620» and with several CMake versions.
I tried reinstalling this with sdkManager, also deleted the folder with ndk. After changing to 18.1.5063045 it becomes ok.

@rwilliams-janacare

Those error messages

CMake Error at ... (project):
    No CMAKE_C_COMPILER could be found.
-- Configuring incomplete, errors occurred!
See also ".../CMakeFiles/CMakeOutput.log".
See also ".../CMakeFiles/CMakeError.log".

or

CMake Error: your CXX compiler: "CMAKE_CXX_COMPILER-NOTFOUND" was not found.
Please set CMAKE_CXX_COMPILER to a valid compiler path or name.
...
-- Configuring incomplete, errors occurred!

just mean that CMake was unable to find your C/CXX compiler to compile a simple test program (one of the first things CMake tries while detecting your build environment).

The steps to find your problem are dependent on the build environment you want to generate. The following tutorials are a collection of answers here on Stack Overflow and some of my own experiences with CMake on Microsoft Windows 7/8/10 and Ubuntu 14.04.

Preconditions

  • You have installed the compiler/IDE and it was able to once compile any other program (directly without CMake)

    • You e.g. may have the IDE, but may not have installed the compiler or supporting framework itself like described in Problems generating solution for VS 2017 with CMake or How do I tell CMake to use Clang on Windows?
  • You have the latest CMake version

  • You have access rights on the drive you want CMake to generate your build environment

  • You have a clean build directory (because CMake does cache things from the last try) e.g. as sub-directory of your source tree

    Windows cmd.exe

      > rmdir /s /q VS2015
      > mkdir VS2015
      > cd VS2015
    

    Bash shell

      $ rm -rf MSYS
      $ mkdir MSYS
      $ cd MSYS
    

    and make sure your command shell points to your newly created binary output directory.

General things you can/should try

  1. Is CMake able find and run with any/your default compiler? Run without giving a generator

     > cmake ..
     -- Building for: Visual Studio 14 2015
     ...
    

    Perfect if it correctly determined the generator to use — like here Visual Studio 14 2015

  2. What was it that actually failed?

    In the previous build output directory look at CMakeFilesCMakeError.log for any error message that make sense to you or try to open/compile the test project generated at CMakeFiles[Version]CompilerIdC|CompilerIdCXX directly from the command line (as found in the error log).

CMake can’t find Visual Studio

  1. Try to select the correct generator version:

     > cmake --help
     > cmake -G "Visual Studio 14 2015" ..
    
  2. If that doesn’t help, try to set the Visual Studio environment variables first (the path could vary):

     > "c:Program Files (x86)Microsoft Visual Studio 14.0VCvcvarsall.bat"
     > cmake ..
    

    or use the Developer Command Prompt for VS2015 short-cut in your Windows Start Menu under All Programs/Visual Studio 2015/Visual Studio Tools (thanks at @Antwane for the hint).

Background: CMake does support all Visual Studio releases and flavors (Express, Community, Professional, Premium, Test, Team, Enterprise, Ultimate, etc.). To determine the location of the compiler it uses a combination of searching the registry (e.g. at HKEY_LOCAL_MACHINESOFTWAREMicrosoftVisualStudio[Version];InstallDir), system environment variables and — if none of the others did come up with something — plainly try to call the compiler.

CMake can’t find GCC (MinGW/MSys)

  1. You start the MSys bash shell with msys.bat and just try to directly call gcc

     $ gcc
     gcc.exe: fatal error: no input files
     compilation terminated.
    

    Here it did find gcc and is complaining that I didn’t gave it any parameters to work with.

    So the following should work:

     $ cmake -G "MSYS Makefiles" ..
     -- The CXX compiler identification is GNU 4.8.1
     ...
     $ make
    

    If GCC was not found call export PATH=... to add your compilers path (see How to set PATH environment variable in CMake script?) and try again.

  2. If it’s still not working, try to set the CXX compiler path directly by exporting it (path may vary)

     $ export CC=/c/MinGW/bin/gcc.exe
     $ export CXX=/c/MinGW/bin/g++.exe
     $ cmake -G "MinGW Makefiles" ..
     -- The CXX compiler identification is GNU 4.8.1
     ...
     $ mingw32-make
    

    For more details see How to specify new GCC path for CMake

    Note: When using the «MinGW Makefiles» generator you have to use the mingw32-make program distributed with MinGW

  3. Still not working? That’s weird. Please make sure that the compiler is there and it has executable rights (see also preconditions chapter above).

    Otherwise the last resort of CMake is to not try any compiler search itself and set CMake’s internal variables directly by

     $ cmake -DCMAKE_C_COMPILER=/c/MinGW/bin/gcc.exe -DCMAKE_CXX_COMPILER=/c/MinGW/bin/g++.exe ..
    

    For more details see Cmake doesn’t honour -D CMAKE_CXX_COMPILER=g++ and Cmake error setting compiler

    Alternatively those variables can also be set via cmake-gui.exe on Windows. See Cmake cannot find compiler

Background: Much the same as with Visual Studio. CMake supports all sorts of GCC flavors. It searches the environment variables (CC, CXX, etc.) or simply tries to call the compiler. In addition it will detect any prefixes (when cross-compiling) and tries to add it to all binutils of the GNU compiler toolchain (ar, ranlib, strip, ld, nm, objdump, and objcopy).

Hi,

EDIT: Apparently if we specify LANGUAGES CXX in project, cmake doesn’t check for C compiler. So that issue is solved but it is still not taking dpcpp as a valid CXX compiler and throwing the error:

    Building CXX object CMakeFiles/cmTC_7c364.dir/testCXXCompiler.cxx.obj
    "C:/Program Files (x86)/Intel/oneAPI/compiler/latest/windows/bin/dpcpp.exe"  /nologo -TP   -Wno-sycl-strict  /MDd /Zi /Ob0 /Od /RTC1   /FoCMakeFiles/cmTC_7c364.dir/testCXXCompiler.cxx.obj /FdCMakeFiles/cmTC_7c364.dir/ -c C:/Users/intel/Downloads/cudacode/dpct_repos/libSGM_OneAPI/build/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
    dpcpp: error: no such file or directory: 'C:/Program Files/Git/nologo'
    dpcpp: error: no such file or directory: 'C:/Program Files/Git/MDd'
    dpcpp: error: no such file or directory: 'C:/Program Files/Git/Zi'
    dpcpp: error: no such file or directory: 'C:/Program Files/Git/Ob0'
    dpcpp: error: no such file or directory: 'C:/Program Files/Git/Od'
    dpcpp: error: no such file or directory: 'C:/Program Files/Git/RTC1'
    dpcpp: error: no such file or directory: 'C:/Program Files/Git/FoCMakeFiles/cmTC_7c364.dir/testCXXCompiler.cxx.obj'
    dpcpp: error: no such file or directory: 'C:/Program Files/Git/FdCMakeFiles/cmTC_7c364.dir/'
    make.exe[1]: *** [CMakeFiles/cmTC_7c364.dir/testCXXCompiler.cxx.obj] Error 1
    make.exe[1]: Leaving directory `C:/Users/intel/Downloads/cudacode/dpct_repos/libSGM_OneAPI/build/CMakeFiles/CMakeTmp'
    make.exe: *** [cmTC_7c364/fast] Error 2

And I can’t use clang++ as compiler as mentioned below.

—————————————

tl;dr: how do I invoke cmake so that I can use dpcpp as c++ compiler on windows 10 (to generate Makefile)?

I am trying to build a library+test app (with gtest) however my issue is with CMAKE on windows 10.

It appears that with beta08, dpcpp interface has become more like MSVC compiler (switches starting with / instead of -).

If I use command 

cmake -G "Unix Makefiles" -D CMAKE_CXX_COMPILER=dpcpp ..

It finds gcc as c compiler and complains that clang & msvc can’t be mixed.

CMake Error at C:/Program Files/CMake/share/cmake-3.16/Modules/Platform/Windows-Clang.cmake:104 (message):
  The current configuration mixes Clang and MSVC or some other CL compatible
  compiler tool.  This is not supported.  Use either clang or MSVC as both C
  and C++ compilers.

 if I give command:

cmake -G "Unix Makefiles" -D CMAKE_C_COMPILER=cl -D CMAKE_CXX_COMPILER=clang++ ..

It finds MSVC 19.23.28106.4 as C compiler and fails to compiler test c program with errors like;

Building C object CMakeFiles/cmTC_bafff.dir/testCCompiler.c.obj
    "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.23.28105/bin/Hostx64/x64/cl.exe"  /nologo   /DWIN32 /D_WINDOWS /W3  /MDd /Zi /Ob0 /Od /RTC1   /FoCMakeFiles/cmTC_bafff.dir/testCCompiler.c.obj /FdCMakeFiles/cmTC_bafff.dir/ /FS -c C:/Users/intel/Downloads/cudacode/dpct_repos/libSGM_OneAPI/build/CMakeFiles/CMakeTmp/testCCompiler.c
    Microsoft (R) C/C++ Optimizing Compiler Version 19.23.28106.4 for x64
    Copyright (C) Microsoft Corporation.  All rights reserved.

    cl : Command line warning D9024 : unrecognized source file type 'C:/Program Files/Git/nologo', object file assumed
    cl : Command line warning D9027 : source file 'C:/Program Files/Git/nologo' ignored
    cl : Command line warning D9024 : unrecognized source file type 'C:/Program Files/Git/DWIN32', object file assumed
    cl : Command line warning D9027 : source file 'C:/Program Files/Git/DWIN32' ignored
    cl : Command line warning D9024 : unrecognized source file type 'C:/Program Files/Git/D_WINDOWS', object file assumed
    cl : Command line warning D9027 : source file 'C:/Program Files/Git/D_WINDOWS' ignored
    cl : Command line warning D9024 : unrecognized source file type 'C:/Program Files/Git/W3', object file assumed
    cl : Command line warning D9027 : source file 'C:/Program Files/Git/W3' ignored
    cl : Command line warning D9024 : unrecognized source file type 'C:/Program Files/Git/MDd', object file assumed
    cl : Command line warning D9027 : source file 'C:/Program Files/Git/MDd' ignored

If I add following to CMakeLists.txt file

set(CMAKE_CXX_COMPILER "dpcpp")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-sycl-strict")

and give command

cmake -G "Unix Makefiles" ..

It again finds gcc and complains that Clang and MSVC can not be mixed (as in first case above)

If I use command (without adding dpcpp to CMakeLists.txt file)

cmake -G "Unix Makefiles" -D CMAKE_C_COMPILER=clang -D CMAKE_CXX_COMPILER=clang++ ..

It generates build files correctly but when I run make, it compiles my main source but gives following error (the source file is using dpct::device_vector so it includes dpct/dpstd_utils.hpp) for test case files:

[ 43%] Linking CXX static library sgm.lib
[ 43%] Built target sgm
Scanning dependencies of target gtest
[ 46%] Building CXX object test/googletest/googlemock/gtest/CMakeFiles/gtest.dir/src/gtest-all.cc.obj
[ 50%] Linking CXX static library gtestd.lib
[ 50%] Built target gtest
Scanning dependencies of target sgm-test
[ 53%] Building CXX object test/CMakeFiles/sgm-test.dir/census_transform_test.dp.cpp.obj
In file included from C:/Users/intel/Downloads/cudacode/dpct_repos/libSGM_OneAPI/test/census_transform_test.dp.cpp:3:
In file included from C:Program Files (x86)InteloneAPIdpcpp-ctlatestenv..includedpct/dpstd_utils.hpp:26:
In file included from C:Program Files (x86)InteloneAPIcompilerlatestwindowsincludedpstd/execution:49:
In file included from C:Program Files (x86)InteloneAPIcompilerlatestwindowsincludeoneapi/dpl/pstl/glue_execution_defs.h:59:
In file included from C:Program Files (x86)InteloneAPIcompilerlatestwindowsincludeoneapi/dpl/pstl/hetero/algorithm_impl_hetero.h:21:
In file included from C:Program Files (x86)InteloneAPIcompilerlatestwindowsincludeoneapi/dpl/pstl/hetero/../parallel_backend.h:22:
In file included from C:Program Files (x86)InteloneAPIcompilerlatestwindowsincludeoneapi/dpl/pstl/hetero/dpcpp/parallel_backend_sycl.h:27:
In file included from C:Program Files (x86)InteloneAPIcompilerlatestwindowsincludeoneapi/dpl/pstl/hetero/dpcpp/../../iterator_impl.h:23:
In file included from C:Program Files (x86)InteloneAPIcompilerlatestwindowsincludeoneapi/dpl/pstl/utils.h:31:
C:Program Files (x86)InteloneAPIcompilerlatestwindowsincludeoneapi/dpl/pstl/hetero/dpcpp/sycl_iterator.h:178:59: error:
      no template named 'mode_tag_t' in namespace 'cl::sycl'
                                                    sycl::mode_tag_t<Mode> tag)
                                                    ~~~~~~^
C:Program Files (x86)InteloneAPIcompilerlatestwindowsincludeoneapi/dpl/pstl/hetero/dpcpp/sycl_iterator.h:185:60: error:
      no template named 'mode_tag_t' in namespace 'cl::sycl'
    begin(sycl::buffer<T, /*dim=*/1, Allocator> buf, sycl::mode_tag_t<Mode> tag, sycl::property::noinit)
                                                     ~~~~~~^
C:Program Files (x86)InteloneAPIcompilerlatestwindowsincludeoneapi/dpl/pstl/hetero/dpcpp/sycl_iterator.h:185:98: error:
      no type named 'noinit' in namespace 'cl::sycl::property'
    begin(sycl::buffer<T, /*dim=*/1, Allocator> buf, sycl::mode_tag_t<Mode> tag, sycl::property::noinit)
                                                                                 ~~~~~~~~~~~~~~~~^
C:Program Files (x86)InteloneAPIcompilerlatestwindowsincludeoneapi/dpl/pstl/hetero/dpcpp/sycl_iterator.h:192:70: error:
      no type named 'noinit' in namespace 'cl::sycl::property'
    begin(sycl::buffer<T, /*dim=*/1, Allocator> buf, sycl::property::noinit)
                                                     ~~~~~~~~~~~~~~~~^
C:Program Files (x86)InteloneAPIcompilerlatestwindowsincludeoneapi/dpl/pstl/hetero/dpcpp/sycl_iterator.h:199:100: error:
      no template named 'mode_tag_t' in namespace 'cl::sycl'
__internal::sycl_iterator<Mode, T, Allocator> end(sycl::buffer<T, /*dim=*/1, Allocator> buf, sycl::mode_tag_t<Mode> tag)
                                                                                             ~~~~~~^
C:Program Files (x86)InteloneAPIcompilerlatestwindowsincludeoneapi/dpl/pstl/hetero/dpcpp/sycl_iterator.h:206:58: error:
      no template named 'mode_tag_t' in namespace 'cl::sycl'
    end(sycl::buffer<T, /*dim=*/1, Allocator> buf, sycl::mode_tag_t<Mode> tag, sycl::property::noinit)
                                                   ~~~~~~^
C:Program Files (x86)InteloneAPIcompilerlatestwindowsincludeoneapi/dpl/pstl/hetero/dpcpp/sycl_iterator.h:206:96: error:
      no type named 'noinit' in namespace 'cl::sycl::property'
    end(sycl::buffer<T, /*dim=*/1, Allocator> buf, sycl::mode_tag_t<Mode> tag, sycl::property::noinit)
                                                                               ~~~~~~~~~~~~~~~~^
C:Program Files (x86)InteloneAPIcompilerlatestwindowsincludeoneapi/dpl/pstl/hetero/dpcpp/sycl_iterator.h:213:94: error:
      no type named 'noinit' in namespace 'cl::sycl::property'
                                                                             sycl::property::noinit)
                                                                             ~~~~~~~~~~~~~~~~^
8 errors generated.
make[2]: *** [test/CMakeFiles/sgm-test.dir/census_transform_test.dp.cpp.obj] Error 1
make[1]: *** [test/CMakeFiles/sgm-test.dir/all] Error 2
make: *** [all] Error 2

I have tried to compile this file (census_transform_test.dp.cpp) as stand alone file with clang++ and I get same errors but not when i use dpcpp

So my question is, how do I invoke cmake so that I can use dpcpp as c++ compiler on windows 10?

I want to generate make files and not visual studio solution.

I converted all the files from repo libSGM and now trying to build it along with tests so that I can validate the dpct generated cpp code. I can share the converted code if required.

Regards,
Gagan

Понравилась статья? Поделить с друзьями:
  • Ошибка cls launched application does not respond
  • Ошибка clr20r3 windows 7 о чем
  • Ошибка clr 8007000e работа программы будет прекращена
  • Ошибка clr 8007000e cyberpunk 2077
  • Ошибка clr 80070005 работа программы будет прекращена что это