NVCC compilation of Eclipse IDE project in Windows 10

Home and Applets > Download SVD-GPU Application Source Code > NVCC Compilation of Eclipse IDE Project

NVCC is a proprietary compiler by Nvidia intended for use with CUDA. CUDA code runs on both the CPU and GPU. NVCC compiles both *.cu and *.cpp files.
Eclipse IDE in Windows 10 is used for our projects. Visual Studio Community 2015 with update 3, x64 (Release date: 27/Jun/2016) and CUDA toolkit 8.0 GA1 (sept 2016) are needed.

*** Outline ***

  1. User environment variables in Windows 10
  2. CUDA C++ 64-bit HelloWorld project with nvcc in MinGW GCC toolchain
  3. CUDA C++ 64-bit Sum2Array project with nvcc in MinGW GCC toolchain
  4. CUDA C 64-bit bandwidth project with nvcc in MinGW GCC toolchain
  5. C++ 64-bit shared library svdComplexDevice1.dll project with nvcc in Microsoft Visual C++ toolchain
  6. Mandelbrot project with nvcc in Microsoft Visual C++ toolchain
  7. References

User environment variables in Windows 10

To reduce the numbers of messages during the setup of any 64-bit project, we have already included the six paths into user environment variables (INCLUDE, Path, and LIB) of Windows 10:

  1. C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include
    for cancelling wavy underlines (iostream)
    C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt
    for corecrt.h
  2. C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64
    for the compiler cl.exe
  3. C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib\amd64
    for msvcprt.lib
    C:\Program Files (x86)\Windows Kits\10\Lib\10.0.17763.0\um\x64
    for kernel32.lib
    C:\Program Files (x86)\Windows Kits\10\Lib\10.0.17763.0\ucrt\x64
    for ucrt.lib

CUDA C++ 64-bit HelloWorld project with nvcc in MinGW GCC toolchain

  1. Launch Eclipse IDE for Java Developers.
    Generation of source file extension .cu. for the eclipse-workspace
    Select Window menu, then Preferences.

  2. Click C/C++ then File Types.

  3. Click New... button.
    C/C++ File Type panel appears.

    Provide *.cu for Pattern.
    Select C++ Source File for Type choice box.
    Click OK button.

  4. Click Apply and Close button.
  5. Select File menu, then New, finally C/C++ Project.
    New C/C++ Project panel appears.
    Select C++ Managed Build.

    Click Next > button.
  6. C++ Project panel appears.
    Provide Project name: CppMingw64HWnvcc.
    Select Empty Project for Executable.
    Select MinGW GCC in toolchains.
    Click Finish button.
  7. Project folder CppMingw64HWnvcc appears in Project Explorer. It contains Includes folder.

  8. Right click project folder CppMingw64HWnvcc. Select New then Source Folder.
    New Source Folder panel appears.
    Provide src for Folder name.
    Click Finish button.
  9. src folder appears in project folder.
    Right click source folder src. Select New then Source File.
    New Source File panel appears.
    Provide helleocu.cu for Source file.
    Click Finish button.

  10. Copy and paste Hello World program of Ingemar Ragnemalm into helleocu.cu.

  11. Add three include statements:
    #include <cuda_runtime.h>
    #include <cuda.h>
    #include "device_launch_parameters.h"

    Press CTRL S for save.

    Most wavy underlines in the source code desappear.
  12. Right click CppMingw64HWnvcc project folder in Project Explorer then select Properties.
    Properties for CppMingw64HWnvcc panel appears.
    Click C/C++ Build then Build Variables.
    Provide data using Add... button.
    NVCC
    File
    C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin\nvcc

    Click Apply button.
    Click Apply and Close button.
  13. Right click the source file helleocu.cu in Project Explorer, then select Properties.
    Properties for helleocu.cu panel appears.
    Select C/C++ Build then Settings.
    Click Build Steps tab.
    Select Apply Custom Build Step Overriding Other Tools in Custom Build Step Applicability choice box.
    Provide helleocu.obj for Output file name(s).
    Provide ${NVCC} -I "C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt" "..\src\helleocu.cu" --output-file "src\helleocu.obj" for Command.

    Click Apply button.
    Click Apply and Close button.
  14. Select Project menu then Build Project, or press the hammer icon.
    Binaries and Debug folders appear in project folder.

    A message generated by nvcc compiler is shown on CDT Build Console.
  15. Right click CppMingw64HWnvcc project in Project Explorer then select Refresh.

    More folder and files appear.
  16. Select Run menu then Run.

    Hello World! appears on Console tab.

CUDA C++ 64-bit Sum2Array project with nvcc in MinGW GCC toolchain

  1. Launch Eclipse IDE for Java Developers.
    Select File menu, then New, finally C/C++ Project.
    New C/C++ Project panel appears.
    Select C++ Managed Build.

    Click Next > button.
  2. C++ Project panel appears.
    Provide Project name: CppMingw64Sum2Arraynvcc.
    Select Empty Project for Executable.
    Select MinGW GCC in toolchains.
    Click Finish button.
  3. Project folder CppMingw64Sum2Arraynvcc appears in Project Explorer. It contains Includes folder.
  4. Right click project folder CppMingw64Sum2Arraynvcc. Select New then Source Folder.
    New Source Folder panel appears.
    Provide src for Folder name.
    Click Finish button.
  5. src folder appears in project folder.
    Right click source folder src. Select New then Source File.
    New Source File panel appears.
    Provide Sum2Array.cu for Source file.
    Click Finish button.
  6. Copy and paste Sum2Array program from RTP Tutorial into Sum2Array.cu.

  7. Right click CppMingw64Sum2Arraynvcc project folder in Project Explorer then select Properties.
    Properties for CppMingw64Sum2Arraynvcc panel appears.
    Click C/C++ Build then Build Variables.
    Provide data using Add... button.
    CUDA_INC_PATH
    Path
    C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\include

    NVCC
    File
    C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin\nvcc

    INCLUDE
    Path
    C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt

    Click Apply button.
  8. Click Settings in C/C++ Build.
    Click Includes for GCC C++ Compiler in Tool Settings tab.
    Add "${CUDA_INC_PATH}" in Include paths (-I).

    Click Apply button.
    Click Apply and Close button.
  9. Add three include statements:
    #include <cuda_runtime.h>
    #include <cuda.h>
    #include "device_launch_parameters.h"

    Press CTRL S for save.

    Thanks to the four include statements (one in Settings and three in the source code), most wavy underlines in source code desappear.
  10. Right click the source file Sum2Array.cu in Project Explorer, then select Properties.
    Properties for Sum2Array.cu panel appears.
    Select C/C++ Build then Settings.
    Click Build Steps tab.
    Select Apply Custom Build Step Overriding Other Tools in Custom Build Step Applicability choice box.
    Provide Sum2Array.obj for Output file name(s).
    Provide ${NVCC} -I "${INCLUDE}" "..\src\Sum2Array.cu" -o "src\Sum2Array.obj" for Command.

    Click Apply button.
    Click Apply and Close button.
  11. Select Project menu then Build Project, or press the hammer icon.
    Binaries and Debug folders appear in project folder.

    A message generated by nvcc compiler is shown on CDT Build Console.
  12. Right click CppMingw64HWnvcc project in Project Explorer then select Refresh.

    More folder and files appear.
  13. Select Run menu then Run.

    Array addition appears on Console tab.

CUDA C 64-bit bandwidth project with nvcc in MinGW GCC toolchain

  1. Launch Eclipse IDE for Java Developers.
    Select File menu, then New, finally C/C++ Project.
    New C/C++ Project panel appears.
    Select C Managed Build.

    Click Next > button.
  2. C Project panel appears.
    Provide Project name: CMingw64bandwidthnvcc.
    Select Empty Project for Executable.
    Select MinGW GCC in Toolchains.
    Click Finish button.
  3. Project folder CMingw64bandwidthnvcc appears in Project Explorer. It contains Includes folder.
  4. Right click project folder CMingw64bandwidthnvcc. Select New then Source Folder.
    New Source Folder panel appears.
    Provide src for Folder name.
    Click Finish button.
  5. src folder appears in project folder.
    Right click source folder src. Select New then Source File.
    New Source File panel appears.
    Provide bandwidth.cu for Source file.
    Click Finish button.
  6. Copy and paste the file C:\ProgramData\NVIDIA Corporation\CUDA Samples\v8.0\1_Utilities\bandwidthTest\bandwidthTest.cu into the empty source file.

  7. Right click CMingw64bandwidthnvcc project folder in Project Explorer then select Properties.
    Properties for CMingw64bandwidthnvcc panel appears.
    Click C/C++ Build then Build Variables.
    Provide data using Add... button.
    NVCC
    File
    C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin\nvcc
    INCLUDE
    INCLUDE1
    Path
    C:\ProgramData\NVIDIA Corporation\CUDA Samples\v8.0\common\inc
    CUDA_INC_PATH
    Path
    C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\include
    CUDA_LIB_PATH_64
    Path
    C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\lib\x64

    Click Apply button.
  8. Click Settings in C/C++ Build.
    Click Includes for GCC C Compiler in Tool Settings tab.
    Add "${CUDA_INC_PATH}", "${INCLUDE}", and "${INCLUDE1}" in Include paths (-I).

    Click Apply button.
  9. Click Libraries for MinGW C Linker in Tool Settings tab.
    Add cudart_static in Libraries (-I).
    Add "${CUDA_LIB_PATH_64}" in Library search path paths (-L).

    Click Apply button.
    Click Apply and Close button.
  10. Right click the source file bandwidth.cu in Project Explorer, then select Properties.
    Properties for bandwidth.cu panel appears.
    Select C/C++ Build then Settings.
    Click Build Steps tab.
    Select Apply Custom Build Step Overriding Other Tools in Custom Build Step Applicability choice box.
    Provide bandwidth.o for Output file name(s).
    Provide ${NVCC} -Wno-deprecated-gpu-targets -I "${INCLUDE}" -I "${INCLUDE1}" "..\src\bandwidth.cu" -o "src\bandwidth.o" for Command.

    Click Apply button.
    Click Apply and Close button.
  11. Select Project menu then Build Project, or press the hammer icon.
    Binaries and Debug folders appear in project folder.

    A message generated by nvcc compiler is shown on CDT Build Console.
  12. Right click CMingw64bandwidthnvcc project in Project Explorer then select Refresh.

    More folder and files appear.
  13. Select Run menu then Run.

    Click Local C/C++ Application.
    Click OK button.

  14. Data appear on Console tab.
  1. Identical procedure applied to matrixMul.cu generates:

  2. Right click the source file matrixMul.cu in Project Explorer, then select Properties.
    Properties for matrixMul.cu panel appears.
    Select C/C++ Build then Settings.
    Click Build Steps tab.
    Select Apply Custom Build Step Overriding Other Tools in Custom Build Step Applicability choice box.
    Provide matrixMul.o for Output file name(s).
    Provide ${NVCC} -Wno-deprecated-gpu-targets -I "${INCLUDE}" -I "${INCLUDE1}" "..\src\matrixMul.cu" -o "src\matrixMul.o" for Command.

    Click Apply button.
    Click Apply and Close button.
  3. Select Project menu then Build Project, or press the hammer icon.
    Binaries and Debug folders appear in project folder.

    A message generated by nvcc compiler is shown on CDT Build Console.
  4. Select Run menu then Run. Click Local C/C++ Application. Click OK button.

    Data appear on Console tab.

C++ 64-bit shared library svdComplexDevice1.dll project with nvcc in Microsoft Visual C++ toolchain

  1. The svdComplexDevice1.dll project is that obtained with Microsoft Visual C++ toolchain in Eclipe IDE for Java Developers:

    Now, we use Nvidia nvcc compiler to rebuild this project.
  2. Right click svdComplexDevice1 project in Explorer Project then select Properties.
    Properties for svdComplexDevice1 panel appears.
    Click C/C++ Build then Build Variables.
    Click Add... button.
    Add NVCC
    File
    C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin\nvcc

    Click Apply button.
  3. Click Settings.
    The four include folders are shown: "${CULA_INC_PATH}", "${CUDA_INC_PATH}", "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include", and "C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt"

  4. Similarly, files and paths associated with Linker (link) remain unchanged:

    Click Apply and Close button.
  5. The project must be cleaned. Select Project menu, then Clean...
    Clean panel appears.
    Tick the project.

    Click Clean button.
  6. The project folder contains two files only.

  7. Right click the source file svdComplexDevice1.cpp in Project Explorer, then select Properties.
    Properties for svdComplexDevice1.cpp panel appears.
    Select C/C++ Build then Settings.
    Click Build Steps tab.
    Select Apply Custom Build Step Overriding Other Tools in Custom Build Step Applicability choice box.
    Provide svdComplexDevice1.obj for Output file name(s).
    Provide ${NVCC} -I "${CULA_INC_PATH}" -I "${CUDA_INC_PATH}" -c "..\svdComplexDevice1.cpp" -o "svdComplexDevice1.obj" for Command.

    Click Apply button.
    Click Apply and Close button.
  8. Select Project menu then Build Project, or press the hammer icon.
    Archives, Binaries, and Debug folders appear in project folder.
    There is no Include folder.
    64-bit shared library svdComplexDevice1.dll is in Debug folder.

    The message generated by the compiler is shown on CDT Build Console.

Mandelbrot project with nvcc in Microsoft Visual C++ toolchain

  1. Launch Eclipse IDE for C/C++ Developers.
    Generation of header file extension .cuh. for the eclipse-workspace
    Select Window menu, then Preferences.

  2. Click C/C++ then File Types.

  3. Click New... button.
    C/C++ File Type panel appears.

    Provide *.cuh for Pattern.
    Select C++ Header File for Type choice box.
    Click OK button.

  4. Click Apply and Close button.
  5. Select File menu, then New, finally C/C++ Project.
    New C/C++ Project panel appears. Select C++ Managed Build.

    Click Next > button.
  6. C++ Project panel appears.
    Provide Project name: CppVS64Mandelbrotnvcc
    Select Empty Project in Executable.
    Select Microsoft Visual C++ in Toolchains.
    Click Finish button.
  7. Right click the folder of CppVS64Mandelbrotnvcc in Project Explorer.
    Select New, then Source Folder.
    Provide the name src for Folder name.
    Click Finish button.
  8. Right click the folder src of CppVS64Mandelbrotnvcc in Project Explorer.
    Select New, then Source File.
    Provide the name for Source file: Mandelbrot_cuda.cu
    Click Finish button.
  9. Copy and paste the file C:\ProgramData\NVIDIA Corporation\CUDA Samples\v8.0\2_Graphics\Mandelbrot\Mandelbrot_cuda.cu into the empty source file.
    Press Ctrl S to save Mandelbrot_cuda.cu.
  10. Right click the folder src of CppVS64Mandelbrotnvcc in Project Explorer.
    Select New, then Source File.
    Provide the name for Source file: Mandelbrot.cpp
    Click Finish button.
  11. Copy and paste the file C:\ProgramData\NVIDIA Corporation\CUDA Samples\v8.0\2_Graphics\Mandelbrot\Mandelbrot.cpp into the empty source file.
    Press Ctrl S to save Mandelbrot.cpp.
  12. Right click the folder src of CppVS64Mandelbrotnvcc in Project Explorer.
    Select New, then Source File.
    Provide the name for Source file: Mandelbrot_gold.cpp
    Click Finish button.
  13. Copy and paste the file C:\ProgramData\NVIDIA Corporation\CUDA Samples\v8.0\2_Graphics\Mandelbrot\Mandelbrot_gold.cpp into the empty source file.
    Press Ctrl S to save Mandelbrot_gold.cpp.
  14. Right click the folder src of CppVS64Mandelbrotnvcc in Project Explorer.
    Select New, then Header File.
    Provide the name for Header file: Mandelbrot_kernel.cuh
    Click Finish button.
  15. Copy and paste the file C:\ProgramData\NVIDIA Corporation\CUDA Samples\v8.0\2_Graphics\Mandelbrot\Mandelbrot_kernel.cuh into the empty header file.
    Press Ctrl S to save Mandelbrot_kernel.cuh.
  16. Right click the folder src of CppVS64Mandelbrotnvcc in Project Explorer.
    Select New, then Header File.
    Provide the name for Header file: Mandelbrot_gold.h
    Click Finish button.
  17. Copy and paste the file C:\ProgramData\NVIDIA Corporation\CUDA Samples\v8.0\2_Graphics\Mandelbrot\Mandelbrot_gold.h into the empty header file.
    Press Ctrl S to save Mandelbrot_gold.h.
  18. Right click the folder src of CppVS64Mandelbrotnvcc in Project Explorer.
    Select New, then Header File.
    Provide the name for Header file: Mandelbrot_kernel.h
    Click Finish button.
  19. Copy and paste the file C:\ProgramData\NVIDIA Corporation\CUDA Samples\v8.0\2_Graphics\Mandelbrot\Mandelbrot_kernel.h into the empty header file.
    Press Ctrl S to save Mandelbrot_kernel.h.

  20. Right click CppVS64Mandelbrotnvcc project folder in Project Explorer, then select Properties.
    Properties for CppVS64Mandelbrotnvcc panel appears.
    Click C/C++ Build then Build Variables.
    Provide data using Add... button.
    CUDA_INC_PATH
    Path

    C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\include
    CUDA_LIB_PATH_64
    Path

    C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\lib\x64
    INCLUDE2
    Path

    C:\ProgramData\NVIDIA Corporation\CUDA Samples\v8.0\common\inc
    LIB1
    Path

    C:\ProgramData\NVIDIA Corporation\CUDA Samples\v8.0\common\lib\x64
    NVCC
    File

    C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin\nvcc

    Click Apply button.
  21. Click Settings in C/C++ Build.
    Click Libraries for Linker (link) in Tool Settings tab.
    Provide three libraries (cudart_static.lib, glew64.lib, and freeglut.lib) and their folder location ("${CUDA_LIB_PATH_64}" and "${LIB1}") to the linker.

    Click Apply button.
    Click Apply and Close button.
  22. Right click the source file Mandelbrot_cuda.cu in Project Explorer, then select Properties.
    Properties for Mandelbrot_cuda.cu panel appears.
    Select C/C++ Build then Settings.
    Click Build Steps tab.
    Select Apply Custom Build Step Overriding Other Tools in Custom Build Step Applicability choice box.
    Provide Mandelbrot_cuda.obj for Output file name(s).
    Provide ${NVCC} -I "${INCLUDE2}" -c "..\src\Mandelbrot_cuda.cu" -o "src\Mandelbrot_cuda.obj" for Command.

    Click Apply button.
    Click Apply and Close button.
  23. Right click the source file Mandelbrot.cpp in Project Explorer, then select Properties.
    Properties for Mandelbrot.cpp panel appears.
    Select C/C++ Build then Settings.
    Click Build Steps tab.
    Select Apply Custom Build Step Overriding Other Tools in Custom Build Step Applicability choice box.
    Provide Mandelbrot.obj for Output file name(s).
    Provide ${NVCC} -I "${INCLUDE2}" -c "..\src\Mandelbrot.cpp" -o "src\Mandelbrot.obj" for Command.
    Click Apply button.
    Click Apply and Close button.
  24. Right click the source file Mandelbrot_gold.cpp in Project Explorer, then select Properties.
    Properties for Mandelbrot_gold.cpp panel appears.
    Select C/C++ Build then Settings.
    Click Build Steps tab.
    Select Apply Custom Build Step Overriding Other Tools in Custom Build Step Applicability choice box.
    Provide Mandelbrot_gold.obj for Output file name(s).
    Provide ${NVCC} -I "${INCLUDE2}" -c "..\src\Mandelbrot_gold.cpp" -o "src\Mandelbrot_gold.obj" for Command.
    Click Apply button.
    Click Apply and Close button.
  25. Select Project menu then Build Project, or press the hammer icon.
    Binaries, Archives, and Debug folders appear in project folder.

    64-bit CppVS64Mandelbrotnvcc.exe is available in Debug folder.
    The message on CDT Build Console is avalable as text file.
  26. Copy and paste the two files glew64.dll and freeglut.dll from the folder C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\extras\demo_suite into the folder C:\Users\Papa\eclipse-workspace\CppVS64Mandelbrotnvcc\Debug, the folder containing CppVS64Mandelbrotnvcc.exe.

  27. Double click CppVS64Mandelbrotnvcc.exe in Debug folder to launch the program.

References

  1. ProgrammerSought: Windows 10 installation CUDA10.2
  2. Code Yarns: How to build CUDA programs using CMake
  3. Ingemar Ragnemalm: The real "Hello World!" for CUDA, OpenCL, and GLSL!
  4. Nvidia: CUDA toolkit documentation
  5. Nvidia: Nvcc compiler options on Eclipse
  6. Pizzoli: Tools for building CUDA C files
  7. StackOverflow: How do I tell NVCC to generate an x64 obj?
  8. StackOverflow: Creating DLL from CUDA using nvcc
  9. Microsoft: Compiler options
  10. HelpManual: nvcc help
  11. RPN: man nvcc
  12. MATLAB: 64-bit compile of .cu to .ptxw64 --> 'cannot execute c1xx.dll' (error D8027)
  13. StackOverflow: Cannot open stdio.h
  14. Awasiljew: Eclipse with CUDA
  15. CUDA-Wianki: Eclipse with CUDA
  16. A tingiblog by Thomas Diakos: Getting ready to develop with CUDA in Eclipse under Ubuntu
  17. RIP Tutorial: Sum two arrays with CUDA

Solid-state NMR bibliography for:

Aluminum-27
Antimony-121/123
Arsenic-75
Barium-135/137
Beryllium-9
Bismuth-209
Boron-11
Bromine-79/81
Calcium-43
Cesium-133
Chlorine-35/37
Chromium-53
Cobalt-59
Copper-63/65
Deuterium-2
Gallium-69/71
Germanium-73
Gold-197
Hafnium-177/179
Indium-113/115
Iodine-127
Iridium-191/193
Krypton-83
Lanthanum-139
Lithium-7
Magnesium-25
Manganese-55
Mercury-201
Molybdenum-95/97
Neon-21
Nickel-61
Niobium-93
Nitrogen-14
Osmium-189
Oxygen-17
Palladium-105
Potassium-39/41
Rhenium-185/187
Rubidium-85/87
Ruthenium-99/101
Scandium-45
Sodium-23
Strontium-87
Sulfur-33
Tantalum-181
Titanium-47/49
Vanadium-51
Xenon-131
Zinc-67
Zirconium-91
[Contact me] - Last updated August 30, 2022
Copyright © 2002-2024 pascal-man.com. All rights reserved.