This subject discuss the common compiler- and linker settings needed for all components in your project. This means that your main application will define these settings once (you don't have to configure each file, only the project as a whole). The same goes for each library you use. Why do we do this ? Because the Lotus has built the APIs with these settings, and if we try something else, the application wont probably build at all. You'll be stuck with strange build-errors. If your are "lucky" and get your application built, I might run for a while, and then crash. The crash-reason will be anything but obvious!!
You find the project settings with the menu Project -> Settings (or use ALT+F7). This action brings up this dialog box:
From this dialog box you control the settings per project. This comes in addition to the global settings you set for all projects.
As for many of the dialogs in Visual Studio, you have multiple tabs. By using the little arrows in the upper-right corner, you scroll to the yet invisible tabs.
Also note that the list at the right is controlled by the drop down Settings for. This means that you can have different settings for debug- and release builds. This is quite natural, since the debug-build will contain lots of debug-info while the release build is completely stripped for debug-info.
One nice thing. You may select All configurations in the Settings For. You can then easily change settings that you know will be common for both debug- and release builds.
Well onto the different tabs and dialogs in Project Settings!
Remember that all components in an applications, your own code and libraries etc, must have the same settings. If you use MFC ensure that the use the same model, either Use MFC in a Shared DLL or Use MFC in a Static Library. If you mix these in any of your components, problems will occur during build!
To give you a little flavor of such an error, see below:
nafxcwd.lib(afxmem.obj) : error LNK2005:
"void * __cdecl operator new(unsigned int)"(??2@YAPAXI@Z) already defined in LIBCMTD.lib(new.obj)
Not easy to understand what this really means, but it often turns out that you have mixed MFC support in your application or in some of your libraries.
This is where you feed parameters into your application during debugging! It's also here you specify to use Lotus Notes as the Executable for debug session if you debug a DLL application.
But for the library, just leave as it is - empty.
In this dialog box you have to take care of two things, both in the Project Options field. Visual Studio erronously puts in the option _AFXDLL, even if we're not making a DLL. So if you for example make a library or stand alone application, be sure to remove this option.
In addition, you must add the option W32. This is Notes API related and instruct the Notes APIs to generate Windows code (remember the discussion about multi platform!).
Don't select a new tab from this dialog. Select the next step from the Category-drop down field instead!
The C++ tab - Code Generation categoryThis is one of the dialog boxes that contain almost a little too much information! Well first of all, ensure that the Use run-time library are according to the plans of your application. This is where you specify if your application needs support for so-called multi threaded libraries or not, you also divide between DLL and non-DLL versions, in addition to debug- and release versions! Whoa - a whole bunch of run-time libraries to keep apart! It's not as bad as it might seem at first glance! First of all, the Settings for control whether you get debug- or release libraries as default. Then you only have to decide whether you make a DLL or not, and if you should go for multi threaded libraries or not. I try to clarify:
Be aware that Visual Studio again erronously assumes that you want to make a DLL application! |
The next field to take care of is the Struct member alignment-field:
Remember, I discuss the 1-byte alignment challenge here.
Always set this to 1-byte alignment. always as long as you make anything that even comes near Notes!
If you forget this option, your application will build just fine, and it might even run for a while ... but then ... booom! One of the hardest errors to track, because you end up so very deep in the debugger. Any - if any - error messages will NOT tell you what's wrong.
Up till now you have set compiler and project options. Finally you need to tell your application to link to Lotus Notes API libraries. This is the spot where Visual Studio search the global directories for library files.
In the sample above, you see that the application links with both the Notes C++ API (notescpp.lib) and with the Notes C API (notes.lib). You select the correct API for your application!
If you forget to do this, the linked will complain about missing and non-loading libraries. Straight on the nail in this case!