Detail steps to build HCL Notes/Domino C API Sample Program by using Microsoft Visual Studio 2019

HCL provided C API Toolkit 9.0.1 for HCL Notes/Domino 9.0.1 and C API Toolkit 11.0.1 for HCL Notes/Domino 11.0.1. There are many sample programs in these two C API Toolkit. This article introduce how to use Microsoft Visual Studio 2019 to build these sample programs.

(If you found this article is helpful, please upvote it. If you have additional questions, please add your questions as reply to this article, then I will reply you when I have time. Thanks!)

Please refer to the following steps to create a project in Microsoft Visual Studio 2019 environment and then build Notes/Domino C API program.
<Steps>
1. Start Microsoft Visual Studio 2019, in the following screen click "Continue without code" to show the main window of Visual Studio
2. In the main window of Visual Studio 2019, from menu bar select [File]-[New]-[Project from existing code] , then a wizard is displayed to create a new project.
3. In this wizard, create a new project by the following steps:
3-1. In [What type of project would you like to create?] field, select "Visual C++", then click [Next] button.
3-2. In "Specify Project Location and Source Files" page, input path for the folder where you place source code for C API sample program, and also input the project name, then click [Next] button.
3-3. In "Specify Project Settings" page, select "Project Type" for your project according to the type of the program you want to build
(For example, in this article, I will build a Win32 C API Console Application "copydb" which is a sample program provided in C API Toolkit, so I select "Console application project" as project type, then click [Next] button.
3-4. In "Specify Debug Configuration Setting" page, keep everything as default, then click [Next] button.
3-5. In "Specify Release Configuration Settings" page, keep everything as default, then click [Finish] button.
3-6. Now, a new project was created and displayed as following.
4. From the menu bar of Visual Studio 2019 main window, select [Project]-[Properties], then the properties page dialog for your project is displayed, in this dialog you will set all the information for building your program.
( The default Configuration is for building a program for Debug purpose. You can choose this default Configuration at first to build a program for debug, after you finished debug, you can also change the Configuration to Release, then set everything in the same as what you set in Debug Configuration)
4-1. In the "Additional Include Directories" field on [Configuration Properties]-[C/C++]-[General] tab, input the path of the "include" folder which hold C API header files (.h) provided by C API Toolkit.
For example, I placed C API Toolkit package under D:\works\C_API\notesapi901\ , and the full path of "include" is D:\works\C_API\notesapi901\include , I set this path into "Additional Include Directories" field.
4-2. In the "Additional Options" field on [Configuration Properties]-[C/C++]-[Command Line] tab, add "-DW32".
** In the header files (*.h) provided by C API Toolkit, there are many definitions which are depended on OS Platform, when compile your C API program you should specify your platform by -D option. For example, in this article , I will build a Windows 32 bit Console Application, I set "-DW32" in this page.
4-3. In the "Additional Library Directories" field on [Configuration Properties]-[Linker]-[General] tab, add the path for C API library path used for building C API program. In this article, I build a Windows 32bit Console Application, and will use 32 bit Windows C API library, so I add D:\works\C_API\notesapi901\lib\mswin32 into "Additional Library Directories" field.
4-4. In the "Additional Dependencies" field on [Configuration Properties]-[Linker]-[All Options] tab, add the name for C API library.
The necessary C API library list is described in the following section of the make file of each sample program provided in Notes/Domino 9 C API Toolkit (Although Notes/Domino 11 C API Toolkit does not provide Make file, you can refer to the Make file provide in Notes/Domino 9 C API Toolkit) . For my Windows 32bit Console Application "copydb", you should refer to mswin32.mak which is for building Windows 32 bit platform, and in the following "Link command" section, you can find that
user32.lib and notes.lib are needed to build this program. Since user32.lib is default added to project for building Windows 32 bit console application, you can only add "notes.lib" into "Additional Dependencies" field.
------------
# Link command.
.OBJ.EXE:
$(link) $(linkdebug) $(conflags) -out:$@ $** $(conlibs) \
notes.lib user32.lib
------------
4-5. Click "OK" button on the Properties page Dialog to close this dialog.
5. From the menu bar of Visual Studio 2019 main window, select [Build]-[Build Solution], the your program will be built and generate an .exe file under the Debug folder of your project.
In the sample in this article, copydb.exe will be created under D:\works\C_API\copydb\Debug
6. Then you can add the following necessary setting in your Windows OS environment variable PATH and then execute the .exe file to confirm its behavior.
At first, for the your Windows OS environment variable PATH, as described as following in C API guide , you should add the path for your 32 bit Notes or Domino program folder into PATH
-------------------
PATH should contain:
The Domino or Notes program directory; normally d:\lotus\notes. The Domino or Notes program directory contains the Domino or Notes executables and DLLs. This is required if the DLLs are loaded implicitly. As an alternative, the DLLs may be loaded explicitly by an application. See the chapter "Program Structure: Overview" in this User Guide for more information.
-----------------
This "copydb" program will create a replica for any the database you specified in command line. For example, if you have an existing database intro,nsf under the data folder of your Notes client on your PC, when execute
---------
copydb intro.nsf
---------
It will create a new replica for intro.nsf.
You can also refer to the detail described for this sample program "copydb" in Notes/Domino C API documentation.