Few days ago, I was at Tour Montparnasse for a job interview for young SupInfo students on the 16th floor. Look at the view:
Just a reminder (for me). The command line to rebuild boost library with VS2017 is:
> bjam toolset=msvc-14.1 variant=debug,release threading=multi link=shared address-model=64
First, download log4cpp on sourceforge at http://log4cpp.sourceforge.net/ .Latest version is 1.1.3. Let’s decompress the archive.
Go to logcpp/msvc10 folder. Open the mvc10.sln and upgrade the project to latest SDK and Visual Studio 2017 (v141). Done.
Build the log4cpp project… There is an error about a custom build step on file NTEventLogCategories.mc.
We need to go into the folder msvc10 of the src and compile the event viewer definition file (.mc). You need to open Developer Command VS2017:
MC: Compiling NTEventLogCategories.mc
D:\Dev\log4cpp-1.1.3\log4cpp\msvc10>rc -r -fo NTEventLogCategories.res NTEventLogCategories.rc Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384 Copyright (C) Microsoft Corporation. All rights reserved.
D:\Dev\log4cpp-1.1.3\log4cpp\msvc10>link /MACHINE:IX86 -dll -noentry -out:NTEventLogAppender.dll NTEventLogCategories.res Microsoft (R) Incremental Linker Version 14.12.25830.2
Copyright (C) Microsoft Corporation. All rights reserved.
Then in Visual Studio, remove the NTEventLogCategories.mc file from the project and let’s BUILD !
There is a compiler error. To solve it: add HAVE_SNPRINTF to the Preprocessor definitions… and REBUILD ! Now it is successful:
1> Creating library Debug\log4cpp.lib and object Debug\log4cpp.exp
1>log4cpp.vcxproj -> D:\Dev\log4cpp-1.1.3\log4cpp\msvc10\log4cpp\Debug\log4cpp.dll 1>Done building project “log4cpp.vcxproj”.
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
When you build a Visual Studio project, you have to consider multiple project options:
The Character Set option is very important in the way you will write code. Microsoft wants every developer to build with “Use Unicode Character Set” but bad habits were taken by developers.
They have preferred the option “Use Multi-Byte Character Set (MBCS)” where strings are things you put in “” and that’s all !
So what is the problem Doctor ? Handling Unicode allows you to target multiples languages and it’s the way we build modern softwares.
To help you achieve your migration or your new software, Microsoft provides TCHAR.h with a lot of macros:
– TCHAR means char in MBCS and wchar_t in Unicode
– _T(“toto”) means “toto” in MBCS and L”toto” in Unicode
To properly call routines of the CRT using TCHAR, you have to notice the name of the functions that care of TCHAR : https://docs.microsoft.com/en-us/cpp/c-runtime-library/routine-mappings Example: printf -> Unicode: wprintf, TCHAR: _tprintf
If you use _tprintf and #include , the function _tprintf will be expanded using the right function name.
TCHAR szLisa = _T(“Lisa”);
But the question is : How do I switch from one mode to another. Example, I use STL, I can have std::string or std::wstring. Using STL strings has a mode that let you recover the characters using the c_str() function.
std::wstring s1 = szLisa;
std::wcout << s1 << std::endl;
If you want to dump from one world to another, the STL has a way:
std::string s2(s1.begin(), s1.end());
std::cout << s2 << std::endl;