I have a DLL that contains my CUDA code and recent added a pair .cuh/.cu with cuRAND code to be part of the DLL.
Because there are a lot of linking problems regarding cuRAND, first I wrote a minimalist piece of code just to see if the thing links.
For the sake of completion, the .cuh and .cu are, respectively:
extern "C"
{
void simple_curand_test(void);
}
And
#include "GPU_Rand.cuh"
#include <curand.h>
#include <curand_kernel.h>
void simple_curand_test(void)
{
curandGenerator_t gen;
curandCreateGenerator(&gen, CURAND_RNG_PSEUDO_DEFAULT);
}
Then, my compiler command to generate the DLL is:
nvcc -o bin\GPU_Methods.dll --shared src\GPU_Utils.cu src\GPU_Rand.cu -L"c:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.1\lib\x64" -lcurand
It ends with this error:
Creating library bin/GPU_Methods.lib and object bin/GPU_Methods.exp
tmpxft_000015a0_00000000-44_GPU_Rand.obj : error LNK2019: unresolved external symbol curandCreateGenerator referenced in function simple_curand_test
bin/SCS_GPU.dll : fatal error LNK1120: 1 unresolved externals
If I change the command to make the linker use the variable LIBRARIES, it looks like:
set LIBRARIES="c:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.1\lib\x64"
nvcc -o bin\GPU_Methods.dll --shared src\GPU_Utils.cu src\GPU_Rand.cu -lcurand
Then the error turns to:
nvlink fatal : Could not open input file 'c:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.1\lib\x64'
After spending some days reading and trying multiple combinations of parameters and commands, it is time to ask if you guys can spot what I am missing.
UPDATE - 01/06/2018
These are the environment variables in a command prompt that runs nvcc (some of them were omitted because they are not relevant to the issue and to avoid bloating your screen even more):
ALLUSERSPROFILE=C:\ProgramData
CommonProgramFiles=C:\Program Files\Common Files
CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
CommonProgramW6432=C:\Program Files\Common Files
CUDA_PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.1
CUDA_PATH_V9_1=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.1
FP_NO_HOST_CHECK=NO
HOMEDRIVE=C:
NVCUDASAMPLES9_1_ROOT=C:\ProgramData\NVIDIA Corporation\CUDA Samples\v9.1
NVCUDASAMPLES_ROOT=C:\ProgramData\NVIDIA Corporation\CUDA Samples\v9.1
NVTOOLSEXT_PATH=C:\Program Files\NVIDIA Corporation\NvToolsExt\
OS=Windows_NT
Path=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.1\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.1\libnvvp;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Windows Live\Shared;C:\MiKTeX 2.9\miktex\bin\x64\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Programming\MSYS2\mingw64\bin;C:\Programming\Java\jdk1.8.0_162\bin;C:\Programming\Python365;C:\Programming\Python365\Lib;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\bin\Hostx64\x64
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
PROCESSOR_ARCHITECTURE=AMD64
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 94 Stepping 3, GenuineIntel
PROCESSOR_LEVEL=6
PROCESSOR_REVISION=5e03
ProgramData=C:\ProgramData
ProgramFiles=C:\Program Files
ProgramFiles(x86)=C:\Program Files (x86)
ProgramW6432=C:\Program Files
PROMPT=$P$G
PSModulePath=C:\Windows\system32\WindowsPowerShell\v1.0\Modules\
PUBLIC=C:\Users\Public
PYTHONPATH=C:\Programming\Python365;C:\Programming\Python365\Lib
SESSIONNAME=Console
SystemDrive=C:
SystemRoot=C:\Windows
VS120COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\
windir=C:\Windows
The way I managed to link cuRAND and generate the dll was using Visual Studio instead of the command line. Somehow it has the proper arguments for nvcc to link cuRAND that, I suspect, my environment variables are missing.
Thanks to Robert Crovella for also giving it a try and providing input.
Related
I am trying to set up the boost libraries for C++ in Visual Studio Code: I have extracted the zip file to my program files but when I go to build it all with bootstrap.bat it comes up with this error. It works fine for the first 4 then stops. I have no additional permissions set up
C:\Users\*user*>cd "C:\Program Files\boost\boost_1_78_0"
C:\Program Files\boost\boost_1_78_0>bootstrap.bat
Building Boost.Build engine
LOCALAPPDATA=C:\Users\Alex\AppData\Local
Found with vswhere C:\Program Files\Microsoft Visual Studio\2022\Community
Found with vswhere C:\Program Files\Microsoft Visual Studio\2022\Community
Call_If_Exists "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\..\..\VC\Auxiliary\Build\vcvarsall.bat" AMD64
**********************************************************************
** Visual Studio 2022 Developer Command Prompt v17.0.5
** Copyright (c) 2021 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
###
### Using 'vc143' toolset.
###
C:\Program Files\boost\boost_1_78_0\tools\build\src\engine>"cl" /nologo /MP /MT /TP /Feb2 /wd4996 /O2 /GL /EHsc -DNDEBUG builtins.cpp class.cpp command.cpp compile.cpp constants.cpp cwd.cpp debug.cpp debugger.cpp execcmd.cpp execnt.cpp execunix.cpp filent.cpp filesys.cpp fileunix.cpp frames.cpp function.cpp glob.cpp hash.cpp hcache.cpp hdrmacro.cpp headers.cpp jam.cpp jamgram.cpp lists.cpp make.cpp make1.cpp md5.cpp mem.cpp modules.cpp native.cpp object.cpp option.cpp output.cpp parse.cpp pathnt.cpp pathsys.cpp pathunix.cpp regexp.cpp rules.cpp scan.cpp search.cpp jam_strings.cpp startup.cpp subst.cpp sysinfo.cpp timestamp.cpp variable.cpp w32_getreg.cpp modules/order.cpp modules/path.cpp modules/property-set.cpp modules/regex.cpp modules/sequence.cpp modules/set.cpp /link kernel32.lib advapi32.lib user32.lib
builtins.cpp
class.cpp
command.cpp
compile.cpp
C:\Program Files\boost\boost_1_78_0\tools\build\src\engine\class.cpp : fatal error C1083: Cannot open compiler generated file: 'C:\Program Files\boost\boost_1_78_0\tools\build\src\engine\class.obj': Permission denied
C:\Program Files\boost\boost_1_78_0\tools\build\src\engine\command.cpp : fatal error C1083: Cannot open compiler generated file: 'C:\Program Files\boost\boost_1_78_0\tools\build\src\engine\command.obj': Permission denied
C:\Program Files\boost\boost_1_78_0\tools\build\src\engine\compile.cpp : fatal error C1083: Cannot open compiler generated file: 'C:\Program Files\boost\boost_1_78_0\tools\build\src\engine\compile.obj': Permission denied
C:\Program Files\boost\boost_1_78_0\tools\build\src\engine\builtins.cpp : fatal error C1083: Cannot open compiler generated file: 'C:\Program Files\boost\boost_1_78_0\tools\build\src\engine\builtins.obj': Permission denied
cl : Command line error D8040 : error creating or communicating with child process
C:\Program Files\boost\boost_1_78_0\tools\build\src\engine>dir *.exe
vol drive c
vol serial number
Directory of C:\Program Files\boost\boost_1_78_0\tools\build\src\engine
File Not Found
C:\Program Files\boost\boost_1_78_0\tools\build\src\engine>copy /b .\b2.exe .\bjam.exe
The system cannot find the file specified.
Failed to build Boost.Build engine.
C:\Program Files\boost\boost_1_78_0>
All I want these for is for the Python Library, is there a way to move said library directly into the MINGW include file and ignore the rest that won't work?
i followed all the steps from https://v8.dev/docs/build-gn
to build release-static v8 lib but I'm getting this error :
using VC 2019 , win10 64bit from https://v8.dev/docs/build-gn
doing git branch it shows :
c:\Dev\my\v8\depot_tools\v8\v8>git branch
* (HEAD detached at origin/master)
master
the error I'm getting :
c:\Dev\my\v8\depot_tools\v8\v8>python tools/dev/v8gen.py x64.release
c:\Dev\my\v8\depot_tools\v8\v8>ninja -C out.gn/x64.release
ninja: Entering directory `out.gn/x64.release'
[1/1] Regenerating ninja files
[206/2990] LINK bytecode_builtins_list_generator.exe bytecode_builtins_list_generator.exe.pdb
FAILED: bytecode_builtins_list_generator.exe bytecode_builtins_list_generator.exe.pdb
ninja -t msvc -e environment.x64 -- ..\..\third_party\llvm-build\Release+Asserts\bin\lld-link.exe /nologo -libpath:..\..\third_party\llvm-build\Release+Asserts\lib\clang\12.0.0\lib\windows "-libpath:..\..\..\..\..\..\..\..\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\ATLMFC\lib\x64" "-libpath:..\..\..\..\..\..\..\..\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\lib\x64" "-libpath:..\..\..\..\..\..\..\..\Program Files (x86)\Windows Kits\NETFXSDK\4.8\lib\um\x64" "-libpath:..\..\..\..\..\..\..\..\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\ucrt\x64" "-libpath:..\..\..\..\..\..\..\..\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64" /OUT:./bytecode_builtins_list_generator.exe /PDB:./bytecode_builtins_list_generator.exe.pdb #./bytecode_builtins_list_generator.exe.rsp
lld-link: error: could not open 'obj/v8_wrappers.lib': no such file or directory
[207/2990] LINK torque-language-server.exe torque-language-server.exe.pdb
FAILED: torque-language-server.exe torque-language-server.exe.pdb
ninja -t msvc -e environment.x64 -- ..\..\third_party\llvm-build\Release+Asserts\bin\lld-link.exe /nologo -libpath:..\..\third_party\llvm-build\Release+Asserts\lib\clang\12.0.0\lib\windows "-libpath:..\..\..\..\..\..\..\..\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\ATLMFC\lib\x64" "-libpath:..\..\..\..\..\..\..\..\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\lib\x64" "-libpath:..\..\..\..\..\..\..\..\Program Files (x86)\Windows Kits\NETFXSDK\4.8\lib\um\x64" "-libpath:..\..\..\..\..\..\..\..\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\ucrt\x64" "-libpath:..\..\..\..\..\..\..\..\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64" /OUT:./torque-language-server.exe /PDB:./torque-language-server.exe.pdb #./torque-language-server.exe.rsp
lld-link: error: could not open 'obj/v8_wrappers.lib': no such file or directory
[208/2990] LINK torque.exe torque.exe.pdb
FAILED: torque.exe torque.exe.pdb
ninja -t msvc -e environment.x64 -- ..\..\third_party\llvm-build\Release+Asserts\bin\lld-link.exe /nologo -libpath:..\..\third_party\llvm-build\Release+Asserts\lib\clang\12.0.0\lib\windows "-libpath:..\..\..\..\..\..\..\..\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\ATLMFC\lib\x64" "-libpath:..\..\..\..\..\..\..\..\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\lib\x64" "-libpath:..\..\..\..\..\..\..\..\Program Files (x86)\Windows Kits\NETFXSDK\4.8\lib\um\x64" "-libpath:..\..\..\..\..\..\..\..\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\ucrt\x64" "-libpath:..\..\..\..\..\..\..\..\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64" /OUT:./torque.exe /PDB:./torque.exe.pdb #./torque.exe.rsp
lld-link: error: could not open 'obj/v8_wrappers.lib': no such file or directory
[215/2990] CXX obj/test/unittests/cppgc_unittests_sources/member-unittest.obj
ninja: build stopped: subcommand failed.
I would like to force Bazel to use a new compiler to build my project.
From what I understand I could configure a new toolchain or use some command-line options.
I tried the following options:
-CC=clang bazel build //main:hello-world
-export CC=C:\cygwin64\bin\clang++
- bazel build //main:hello-world --client_env=CC=clang
I think these are not working because if I compile the same hello-world.cc file with
clang hello-world.cc
I get the error:
clang-8: error: linker command failed with exit code 1 (use -v to see invocation)
but with
CC=clang bazel build //main:hello-world
or
bazel build //main:hello-world --client_env=CC=clang
the build is successful.
Any idea why the result is different, and how to solve this?
Where can I check which compiler is Bazel using?
EDIT:
here the output of:
CC=C:\cygwin64\bin\clang bazel build -s //main:hello-world
Starting local Bazel server and connecting to it...
Loading:
Loading: 0 packages loaded
Analyzing: target //main:hello-world (1 packages loaded, 0 targets configured)
Analyzing: target //main:hello-world (11 packages loaded, 18 targets configured)
INFO: Analyzed target //main:hello-world (14 packages loaded, 59 targets configured).
INFO: Found 1 target...
[0 / 6] [Prepa] BazelWorkspaceStatusAction stable-status.txt ... (4 actions, 0 running)
SUBCOMMAND: # //main:hello-world [action 'Compiling main/hello-world.cc', configuration: 1f7c3bee164375155568e7845819f422152903a0240344d14b0c6474746ef185, execution platform: #local_config_platform//:host]
cd C:/cygwin64/home/user/_bazel_user/5r4lncy4/execroot/__main__
SET INCLUDE=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\ATLMFC\include;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\include;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um;C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt;C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared;C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um;C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt;C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt
SET PATH=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\bin\HostX64\x64;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\VC\VCPackages;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\TestWindow;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\bin\Roslyn;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Team Tools\Performance Tools\x64;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Team Tools\Performance Tools;C:\Program Files (x86)\Microsoft Visual Studio\Shared\Common\VSPerfCollectionTools\vs2019\\x64;C:\Program Files (x86)\Microsoft Visual Studio\Shared\Common\VSPerfCollectionTools\vs2019\;C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\x64\;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\FSharp\;C:\Program Files (x86)\Windows Kits\10\bin\10.0.18362.0\x64;C:\Program Files (x86)\Windows Kits\10\bin\x64;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\\MSBuild\Current\Bin;C:\Windows\Microsoft.NET\Framework64\v4.0.30319;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\;;C:\WINDOWS\system32;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\VC\Linux\bin\ConnectionManagerExe
SET PWD=/proc/self/cwd
SET RUNFILES_MANIFEST_ONLY=1
SET TEMP=C:\cygwin64\tmp
SET TMP=C:\cygwin64\tmp
C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.25.28610/bin/HostX64/x64/cl.exe /nologo /DCOMPILER_MSVC /DNOMINMAX /D_WIN32_WINNT=0x0601 /D_CRT_SECURE_NO_DEPRECATE /D_CRT_SECURE_NO_WARNINGS /bigobj /Zm500 /EHsc /wd4351 /wd4291 /wd4250 /wd4996 /I. /Ibazel-out/x64_windows-fastbuild/bin /Iexternal/bazel_tools /Ibazel-out/x64_windows-fastbuild/bin/external/bazel_tools /showIncludes /MD /Od /Z7 /wd4117 -D__DATE__="redacted" -D__TIMESTAMP__="redacted" -D__TIME__="redacted" /Fobazel-out/x64_windows-fastbuild/bin/main/_objs/hello-world/hello-world.obj /c main/hello-world.cc
SUBCOMMAND: # //main:hello-world [action 'Linking main/hello-world.exe', configuration: 1f7c3bee164375155568e7845819f422152903a0240344d14b0c6474746ef185, execution platform: #local_config_platform//:host]
cd C:/cygwin64/home/user/_bazel_user/5r4lncy4/execroot/__main__
SET LIB=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\ATLMFC\lib\x64;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\lib\x64;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\lib\um\x64;C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\ucrt\x64;C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\um\x64;
SET PATH=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\bin\HostX64\x64;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\VC\VCPackages;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\TestWindow;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\bin\Roslyn;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Team Tools\Performance Tools\x64;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Team Tools\Performance Tools;C:\Program Files (x86)\Microsoft Visual Studio\Shared\Common\VSPerfCollectionTools\vs2019\\x64;C:\Program Files (x86)\Microsoft Visual Studio\Shared\Common\VSPerfCollectionTools\vs2019\;C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\x64\;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\FSharp\;C:\Program Files (x86)\Windows Kits\10\bin\10.0.18362.0\x64;C:\Program Files (x86)\Windows Kits\10\bin\x64;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\\MSBuild\Current\Bin;C:\Windows\Microsoft.NET\Framework64\v4.0.30319;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\;;C:\WINDOWS\system32;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\VC\Linux\bin\ConnectionManagerExe
SET PWD=/proc/self/cwd
SET RUNFILES_MANIFEST_ONLY=1
SET TEMP=C:\cygwin64\tmp
SET TMP=C:\cygwin64\tmp
C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.25.28610/bin/HostX64/x64/link.exe #bazel-out/x64_windows-fastbuild/bin/main/hello-world.exe-2.params
Target //main:hello-world up-to-date:
bazel-bin/main/hello-world.exe
INFO: Elapsed time: 4.561s, Critical Path: 0.67s
INFO: 2 processes: 2 local.
INFO: Build completed successfully, 6 total actions
INFO: Build completed successfully, 6 total actions
Any idea why this happens? i am using windows 10. Thank you in advance
When not defining your own toolchain, bazel attempts to perform automatic configuration for you which indeed takes into account value of CC variable when defined. Why your bare compilation attempt has failed is not entirely clear from the part of error message posted, but when in doubt, you can add -s to your bazel command line to see commands called and with that see which compiler has been called:
$ CC=/usr/bin/clang bazel build -s //:hello
INFO: Analyzed target //:hello (1 packages loaded, 15 targets configured).
INFO: Found 1 target...
SUBCOMMAND: # //:greet [action 'Compiling greet.cpp', configuration: dd44f3279b21e91676f65783c46b7b7816026ef7e696e80c251418ec64ffdf5e]
(cd /tmp/_bzl/execroot/__main__ && \
exec env - \
PATH=/bin:/usr/bin:/usr/local/bin \
PWD=/proc/self/cwd \
/usr/bin/clang -U_FORTIFY_SOURCE -fstack-protector -Wall -Wthread-safety -Wself-assign -fcolor-diagnostics -fno-omit-frame-pointer '-std=c++0x' -I/usr/lib64/qt/include -MD -MF bazel-out/k8-fastbuild/bin/_objs/greet/greet.pic.d '-frandom-seed=bazel-out/k8-fastbuild/bin/_objs/greet/greet.pic.o' -fPIC -iquote . -iquote bazel-out/k8-fastbuild/bin -Ibazel-out/k8-fastbuild/bin/_virtual_includes/greet -no-canonical-prefixes -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -c greet.cpp -o bazel-out/k8-fastbuild/bin/_objs/greet/greet.pic.o)
SUBCOMMAND: # //:hello [action 'Compiling hello.cpp', configuration: dd44f3279b21e91676f65783c46b7b7816026ef7e696e80c251418ec64ffdf5e]
(cd /tmp/_bzl/execroot/__main__ && \
exec env - \
PATH=/bin:/usr/bin:/usr/local/bin \
PWD=/proc/self/cwd \
/usr/bin/clang -U_FORTIFY_SOURCE -fstack-protector -Wall -Wthread-safety -Wself-assign -fcolor-diagnostics -fno-omit-frame-pointer '-std=c++0x' -I/usr/lib64/qt/include -MD -MF bazel-out/k8-fastbuild/bin/_objs/hello/hello.pic.d '-frandom-seed=bazel-out/k8-fastbuild/bin/_objs/hello/hello.pic.o' -fPIC -iquote . -iquote bazel-out/k8-fastbuild/bin -iquote external/bazel_tools -iquote bazel-out/k8-fastbuild/bin/external/bazel_tools -Ibazel-out/k8-fastbuild/bin/_virtual_includes/greet -no-canonical-prefixes -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -c hello.cpp -o bazel-out/k8-fastbuild/bin/_objs/hello/hello.pic.o)
SUBCOMMAND: # //:hello [action 'Linking hello', configuration: dd44f3279b21e91676f65783c46b7b7816026ef7e696e80c251418ec64ffdf5e]
(cd /tmp/_bzl/execroot/__main__ && \
exec env - \
PATH=/bin:/usr/bin:/usr/local/bin \
PWD=/proc/self/cwd \
/usr/bin/clang #bazel-out/k8-fastbuild/bin/hello-2.params)
Target //:hello up-to-date:
bazel-bin/hello
INFO: Elapsed time: 1.606s, Critical Path: 0.44s
INFO: 3 processes: 3 linux-sandbox.
INFO: Build completed successfully, 5 total actions
Windows is a bit special / different case: I've started looking at the the corresponding rules_cc, but from there actually followed back to the docs, currently recommended method would be to add a platform definition (e.g. in your workspace root BUILD):
platform(
name = "x64_windows-clang-cl",
constraint_values = [
"#platforms//cpu:x86_64",
"#platforms//os:windows",
"#bazel_tools//tools/cpp:clang-cl",
],
)
And registering the additional toolchain in your WORKSPACE file:
register_execution_platforms(
":x64_windows-clang-cl"
)
register_toolchains(
"#local_config_cc//:cc-toolchain-x64_windows-clang-cl",
)
Then (for now) use --incompatible_enable_cc_toolchain_resolution flag with bazel.
At least at the moment, alternatively you should be able to tell bazel to use LLVM on Windows by running bazel with: --compiler=clang-cl.
You may need to set BAZEL_LLVM (this time) to a directory where LLVM is installed (or try relying on automatic resolution).
That said, it does not look like you could use cygwin LLVM compiler on Windows while still relying on automatic toolchain configuration. I suspect you would really need to define your own toolchain for that (not sure how substantial problems would you encounter crossing the boundary between bazel for Windows and cygwin based compiler each having different idea about what path names to use).
I am using Sublime Text and learning C++. I installed Mingw (also added path) and Sublime Text and added a new build system for taking the external output and input.
Here is the code:
{
"cmd" : ["g++ -std=c++14 '$file_name' -o '$file_base_name' && timeout 4s ./'$file_base_name'<input.txt>output.txt"],
"selector" : "source.c, source.cpp",
"shell": true,
"working_dir" : "$file_path"
}
After pressing Control+B, it threw an error:
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe:D:\Anand\competitive programming\input.txt: file format not recognized; treating as linker script
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe:D:\Anand\competitive programming\input.txt:1: syntax error
collect2.exe: error: ld returned 1 exit status
[Finished in 0.1s with exit code 1]
[shell_cmd: g++ "D:\Anand\competitive programming\input.txt" -o "D:\Anand\competitive programming/input" && "D:\Anand\competitive programming/input"]
[dir: D:\Anand\competitive programming]
[path: C:\MinGW\bin;C:\Program Files\Java\jdk-12.0.2\bin;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files\Git\cmd;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\MinGW\bin]
Error 2:
The system cannot find the path specified.
[Finished in 0.0s with exit code 1]
[cmd: ["g++ -std=c++14 'HelloWorld.cpp' -o 'HelloWorld' && timeout 4s ./'HelloWorld'<input.txt>output.txt"]]
[dir: D:\Anand\competitive programming]
[path: C:\MinGW\bin;C:\Program Files\Java\jdk-12.0.2\bin;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files\Git\cmd;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\MinGW\bin]
You don't need the single quotes surrounding the $ variables, and you don't need the ./, as you're running Windows. Edit your build system to include the following:
"cmd" : ["g++ -std=c++14 $file_name -o $file_base_name && timeout 4s $file_base_name < input.txt > output.txt"],
and you should be all set.
i have a huge CU file which contains my project , im trying to separate it into small CU files , but im getting many gl.h errors , i dont know what to do... it's driving me crazy..
1> Compiling CUDA source file core.cu...
1>
1> C:\Users\igal\Desktop\prj trying to devide files\graph>"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\bin\nvcc.exe" -gencode=arch=compute_10,code=\"sm_10,compute_10\" --use-local-env --cl-version 2010 -ccbin "c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\include" -G0 --keep-dir "Debug" -maxrregcount=0 --machine 32 --compile -D_NEXUS_DEBUG -g -Xcompiler "/EHsc /nologo /Od /Zi /MDd " -o "Debug\core.cu.obj" "C:\Users\igal\Desktop\prj trying to devide files\graph\core.cu"
1>c:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\GL/gl.h(1152): error : this declaration has no storage class or type specifier
1>c:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\GL/gl.h(1152): error : expected a ";"
1>c:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\GL/gl.h(1153): error : this declaration has no storage class or type specifier
1>c:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\GL/gl.h(1153): error : variable "WINGDIAPI" has already been defined
1>c:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\GL/gl.h(1153): error : expected a ";"
and the list goes on..
Since you're on Windows, make sure that you include windows.h before including gl.h, or any other file which may indirectly include gl.h.
As stated on MSDN, this is necessary for OpenGL to work.