First, the procedure for installing Microsoft Visual C++ toolchain in Eclipse IDE
for Java developers and Windows 11 is presented.
Then, a C++ 64-bit HelloWorld project is implemented.
Finally, C++ 64-bit shared library svdComplexDevice1.dll is generated with
Microsoft Visual C++ toochain in Eclipse IDE for Java developers.
Visual Studio Community 2022 is needed.
*** Outline ***
- Provide the paths of cl.exe, nvcc, CUDA, and CULA
in environment variables of Windows 11
- C/C++ Visual C++ support in Eclipse IDE
- C++ 64-bit HelloWorld project with Microsoft Visual C++ toolchain in Eclipse IDE
- C++ 64-bit shared library svdComplexDevice.dll project with Microsoft Visual C++ toolchain in Eclipse IDE
- References
Provide the paths of cl.exe, nvcc, CUDA, and CULA in environment variables of Windows 11
- Right click PC computer then select Properties.
- System panel appears.
Select Advanced system parameters.
System properties panel appears.Click Environment Variables... button.
Environment Variables panel appears. - Select Path in System variable sub-panel.
Click Modify... button. - Modify environment variable panel appears.
Click New button.
Add C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\bin\Hostx64\x64
It contains cl.exe compiler.
Click OK button. - Click New... button in System variables sub-panel.
New System Variable panel appears.
Variable name: NVCC
Variable value: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.5\bin\nvcc
Click OK button. - Similarly, fill the following data in System variables sub-panel:
Variable name: INCLUDE1
Variable value: C:\Users\pm\source\repos\cuda-samples-12.5\Common
It contains helper_cuda.h, helper_functions.h, helper_gl.h and others.
Variable name: INCLUDE2
Variable value: C:\Users\pm\source\repos\cuda-samples-12.5\Common\lib\x64
It contains freeglut.lib and glew64.lib.
Variable name: ASSERT
Variable value: C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\ucrt
It contains assert.h, complex.h.
Variable name: CUDA_INC_PATH
Variable value: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.5\include
It contains the cuda_xx.h files of CUDA.
Variable name: CUDA_LIB_PATH_64
Variable value: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.5\lib\x64Click OK buttons.
C/C++ Visual C++ support in Eclipse IDE
Two ways to install MS Visual C/C++ support for Eclipse IDE in Windows 11 are available:
(1) If Eclipse IDE for Java developers is already installed, install C/C++ programs
from Eclipse IDE.
(2) If Eclipse IDE for C/C++ developers is already installed, install CDT
from Eclipse IDE.
Only the first way is presented.
Eclipse IDE for Java Developers installation in Windows 11
- In Eclipse.org,
click Download x86_64 bit button,
then click Download button for obtaining eclipse-inst-jre-win64.exe.
Click this executable results the choice panel:Select Eclipse IDE for Java Developers.
- Perform the installation of Eclipse IDE for Java Developers.
My Java application folder location is C:\Users\pm\eclipse-workspace. - In Eclipse IDE, select Help menu then Install New Software...
Available Software panel appears. - In Work with, select All Available Sites.
- Tick Programming Languages.
Click Next > button.
- Install Remediation Page panel appears.
Select C/C++ Support (experimental).
Click Next > button.
- Install Details panel appears.
Click Next > button.
- Review Licenses panel appears.
Tick the choice: I accept the terms of the license agreement.
Click Finish button. - In Eclipse IDE.
Select Help menu then About Eclipse IDE.
- Click Installation Details button.
C/C++ Visual C++ Support (experimental) is available.
Click Close button.
C++ 64-bit HelloWorld project with Microsoft Visual C++ toolchain in Eclipse IDE
- Launch Eclipse IDE for Java Developers.
Select File menu, New, then Project.
New Project panel appears:
Select C/C++ then C/C++ Project. Click Next > button. - New C/C++ Project panel appears. Select C++ Managed Build.
Click Next > button.
- C++ Project panel appears.
Provide Project name: vs64HelloWorld
Select Hello World C++ Project in Executable.
Select Microsoft Visual C++ in Toolchains.Click Finish button. - The project folder vs64HelloWorld containing vs64HelloWorld.cpp
appears in Package Explorer of Eclipse.
- Select Project menu then Build Project.
A new folder called Debug containing vs64HelloWorld.exe is added to project folder. Three files called vc140.pdb, vs64HelloWorld.lik, and vs64HelloWorld.pdb, are added to Debug folder. - Select Run menu then Run Configuration.
Click C/C++ Application then vs64HelloWorld Debug.Click Run button. - !!!Hello World!!! appears on Console tab.
C++ 64-bit shared library svdComplexDevice1.dll project with Microsoft Visual C++ toolchain in Eclipse IDE
- Launch Eclipse IDE for Java Developers.
Select File menu, New, then Project.
New Project panel appears:
Select C/C++ then C/C++ Project. Click Next > button. - New C/C++ Project panel appears. Select C++ Managed Build.
Click Next > button.
- New C++ Project panel appears.
Provide Project name: svdComplexDevice1
Select Shared Library then Empty Project.
Select Microsoft Visual C++ in Toolchains.Click Finish button. - The project folder svdComplexDevice1 appears in Package Explorer of Eclipse.
- Right-click the project folder svdComplexDevice1.
Select New, then File.
Create New File panel appears.
Provide the name for Header file: svdComplexDevice1.h
Click Finish button.Click Finish button. - The header svdComplexDevice1.h appears in Package Explorer of Eclipse.
- Copy and past svdComplexDevice1.h
file into the newly created header file.
Press Ctrl S to save svdComplexDevice1.h.
- Similarly, create the file: svdComplexDevice1.cpp
Copy and past svdComplexDevice1.cpp file into the newly created source file.Press Ctrl S to save svdComplexDevice1.cpp.
- Provide the path of include folder of CUDA and that of CULA to compiler.
Include folder contains header files.
Right click svdComplexDevice1 project in Package Explorer then select Properties.
Properties for svdComplexDevice1 panel appears.
Click Settings in C/C++ Build.
Click Preprocessor for C++ Compiler in Tool Settings tab.Click + symbol in top part of Include Path (/I). - Add directoriy path panel appears.
Provide "${CUDA_INC_PATH}" for Directory.
Directory must be enclosed in double quotes because this path contains space characters.Click OK button. - Similarly, provide the path "${CULA_INC_PATH}"
Click Apply button.
- A message apears.
Click Rebuild Index button.
- Provide four libraries (cula_core.lib, cublas.lib,
cudart.lib, and cula_lapack.lib)
and their folder location ("${CUDA_LIB_PATH_64}" and
"${CULA_LIB_PATH_64}")
to the linker.
Click Libraries for Linker (link) in Tool Settings tab.
Library file names are provided with extension .lib like in MS Visual Studio and paths are enclosed in double quotes.
Click Apply and Close button.
A message appears.
Click Rebuild Index button.
Click Apply and Close button.
- The project before Build.
- Select Project menu then Build Project.
64-bit svdComplexDevice1.dll file with 44 kbit size is generated in Debug folder.
A message appears on the CDT Build Console.
References
- Dan Dar3: Eclipse CDT and Microsoft Visual C++ compiler
- StackOverflow: Visual Studio toolchain in Eclipse for C++
- StackOverflow: Cannot find corecrt.h
- StackOverflow: Cannot open file 'kernel32.lib'
- StackOverflow: Cannot open file 'ucrt.lib'
- StackOverflow: cannot open file 'MSVCRTD.lib'