log4cplus / log4cplus

log4cplus is a simple to use C++ logging API providing thread-safe, flexible, and arbitrarily granular control over log management and configuration. It is modelled after the Java log4j API.
https://log4cplus.github.io/log4cplus/
Other
1.65k stars 565 forks source link

Unable to link Qt5-based application using log4cplus #392

Closed retiredracer closed 5 years ago

retiredracer commented 5 years ago

I'm trying to use log4cplus with Qt-based (v5.12.1) application on Windows 10, using VS2017.

I built log4cplus using VS2017. I built both a '-Zc:wchar_t' and a '-Zc:wchar_t-' version. I get undefined externals on methods with 'wchar_t' in parameter list in both cases (using the two differently built libraries).

I also built my test Qt app with both '-Zc:wchar_t' and '-Zc:wchar_t-'. Both resulted in same undefines at link time. I'm not using the Q5DebugAppender.

Here is my code and calls to log4cplus:

#include <log4cplus/logger.h>
#include <log4cplus/loggingmacros.h>
#include <log4cplus/configurator.h>
// #include <log4cplus/initializer.h>

using namespace log4cplus;
using namespace log4cplus::helpers;

void
initLogging() {
    log4cplus::initialize();
    // LogLog::getLogLog()->setInternalDebugging(true);
    Logger root = Logger::getRoot();
    try {
        log4cplus::tstring log4cplusfName(LOG4CPLUS_TEXT ("clientServices/resource/log4cplus.properties"));

        PropertyConfigurator::doConfigure(log4cplusfName);
        Logger fileCat = Logger::getInstance(LOG4CPLUS_TEXT("filelogger"));

        LOG4CPLUS_WARN(root, LOG4CPLUS_TEXT("Testing...."));
        LOG4CPLUS_WARN(root, LOG4CPLUS_TEXT("Writing messages to log...."));
        for (int i = 0; i < 10000; ++i)
            LOG4CPLUS_WARN(fileCat, LOG4CPLUS_TEXT("This is a WARNING...")
                << i);

        // Test that DOS EOLs in property files get removed.
#define TEST_TEXT LOG4CPLUS_TEXT ("this is a test with DOS EOL-->")
        tistringstream propsStream(
            LOG4CPLUS_TEXT("text=") TEST_TEXT LOG4CPLUS_TEXT("\r\n"));
        Properties props(propsStream);
        LOG4CPLUS_ASSERT(root,
            props.getProperty(LOG4CPLUS_TEXT("text")) == TEST_TEXT);
    }
    catch (...) {
        tcout << LOG4CPLUS_TEXT("Exception...") << endl;
        LOG4CPLUS_FATAL(root, LOG4CPLUS_TEXT("Exception occured..."));
    }
}

Here is the compile line for my C++ code:

cl -c -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus /MP4 -Zi -MDd -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 -EHsc /FdbuildTestQt.debug\testQt.vc.pdb -DUNICODE -D_UNICODE -DWIN32 -D_ENABLE_EXTENDED_ALIGNED_STORAGE -DBUILD_DLL -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I. -IC:\Programs\log4cplus-1.2.1\include -I..\model\src -I../flowEngine/src -I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um" -I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt" -I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\shared" -IC:\Programs\Qt-5\5.12.1\msvc2017\include -IC:\Programs\Qt-5\5.12.1\msvc2017\include\QtWidgets -IC:\Programs\Qt-5\5.12.1\msvc2017\include\QtGui -IC:\Programs\Qt-5\5.12.1\msvc2017\include\QtANGLE -IC:\Programs\Qt-5\5.12.1\msvc2017\include\QtCore -ItestQt\mocs -IC:\VulkanSDK\1.0.51.0\include -IC:\Programs\Qt-5\5.12.1\msvc2017\mkspecs\win32-msvc -FobuildTestQt.debug\ @C:\Users\rjl\AppData\Local\Temp\nm2A4E.tmp

It compiles fine.

Here is the link line:

link /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /SUBSYSTEM:CONSOLE "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" /MANIFEST:embed /OUT:binTestQt.debug\testQt.exe @C:\Users\rjl\AppData\Local\Temp\nm3A4D.tmp

with the following 'LIBS':

LIBS          = /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.17763.0\um\x86" /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.17763.0\ucrt\x86" "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.17763.0\ucrt\x86\ucrt.lib" /LIBPATH:C:\Programs\log4cplus-1.2.1\lib-nowchar C:\Programs\log4cplus-1.2.1\lib-nowchar\log4cplusSD.lib "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.17763.0\um\x86\GlU32.lib" "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.17763.0\um\x86\AdvAPI32.lib" "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.17763.0\um\x86\ws2_32.lib" "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.17763.0\um\x86\shell32.lib" "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.17763.0\um\x86\User32.lib" /LIBPATH:..\model\lib.debug ..\model\lib.debug\model.lib /LIBPATH:C:\Programs\Qt-5\5.12.1\msvc2017\lib C:\Programs\Qt-5\5.12.1\msvc2017\lib\Qt5Widgetsd.lib C:\Programs\Qt-5\5.12.1\msvc2017\lib\Qt5Guid.lib C:\Programs\Qt-5\5.12.1\msvc2017\lib\Qt5Cored.lib   

The linker output:

1>testQt.obj : error LNK2019: unresolved external symbol "public: static class log4cplus::Logger __cdecl log4cplus::Logger::getInstance(class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > const &)" (?getInstance@Logger@log4cplus@@SA?AV12@ABV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@@Z) referenced in function "void __cdecl initLogging(void)" (?initLogging@@YAXXZ)
1>testQt.obj : error LNK2019: unresolved external symbol "class std::basic_ostringstream<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > & __cdecl log4cplus::detail::get_macro_body_oss(void)" (?get_macro_body_oss@detail@log4cplus@@YAAAV?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@XZ) referenced in function "void __cdecl initLogging(void)" (?initLogging@@YAXXZ)
1>testQt.obj : error LNK2019: unresolved external symbol "void __cdecl log4cplus::detail::macro_forced_log(class log4cplus::Logger const &,int,class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > const &,char const *,int,char const *)" (?macro_forced_log@detail@log4cplus@@YAXABVLogger@2@HABV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@PBDH2@Z) referenced in function "void __cdecl initLogging(void)" (?initLogging@@YAXXZ)
1>testQt.obj : error LNK2019: unresolved external symbol "void __cdecl log4cplus::detail::macro_forced_log(class log4cplus::Logger const &,int,wchar_t const *,char const *,int,char const *)" (?macro_forced_log@detail@log4cplus@@YAXABVLogger@2@HPB_WPBDH2@Z) referenced in function "void __cdecl initLogging(void)" (?initLogging@@YAXXZ)
1>testQt.obj : error LNK2019: unresolved external symbol "public: __thiscall log4cplus::helpers::Properties::Properties(class std::basic_istream<wchar_t,struct std::char_traits<wchar_t> > &)" (??0Properties@helpers@log4cplus@@QAE@AAV?$basic_istream@_WU?$char_traits@_W@std@@@std@@@Z) referenced in function "void __cdecl initLogging(void)" (?initLogging@@YAXXZ)
1>testQt.obj : error LNK2019: unresolved external symbol "public: class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > const & __thiscall log4cplus::helpers::Properties::getProperty(wchar_t const *)const " (?getProperty@Properties@helpers@log4cplus@@QBEABV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@PB_W@Z) referenced in function "void __cdecl initLogging(void)" (?initLogging@@YAXXZ)
1>testQt.obj : error LNK2019: unresolved external symbol "public: static void __cdecl log4cplus::PropertyConfigurator::doConfigure(class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > const &,class log4cplus::Hierarchy &,unsigned int)" (?doConfigure@PropertyConfigurator@log4cplus@@SAXABV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@AAVHierarchy@2@I@Z) referenced in function "void __cdecl initLogging(void)" (?initLogging@@YAXXZ)
1>testQt.obj : error LNK2001: unresolved external symbol "class std::basic_ostream<wchar_t,struct std::char_traits<wchar_t> > & log4cplus::tcout" (?tcout@log4cplus@@3AAV?$basic_ostream@_WU?$char_traits@_W@std@@@std@@A)
1>binTestQt.debug\testQt.exe : fatal error LNK1120: 8 unresolved externals

There are 8 unresolved externals - all appear to be methods that have 'wchar_t' parameter.

wilx commented 5 years ago

You are trying to use use the static library variant. I think your project should define LOG4CPLUS_STATIC.

retiredracer commented 5 years ago

Thanks for your very quick response!

Oop, good catch. But I get the same results if I use LOG4PLUS_STATIC. Here is the compile line now:

cl -c -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus /MP4 -Zi -MDd -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 -EHsc /FdbuildTestQt.debug\testQt.vc.pdb -DUNICODE -D_UNICODE -DWIN32 -D_ENABLE_EXTENDED_ALIGNED_STORAGE -DLOG4CPLUS_STATIC -DBUILD_DLL -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I. -IC:\Programs\log4cplus-1.2.1\include -I..\model\src -I../flowEngine/src -I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um" -I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt" -I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\shared" -IC:\Programs\Qt-5\5.12.1\msvc2017\include -IC:\Programs\Qt-5\5.12.1\msvc2017\include\QtWidgets -IC:\Programs\Qt-5\5.12.1\msvc2017\include\QtGui -IC:\Programs\Qt-5\5.12.1\msvc2017\include\QtANGLE -IC:\Programs\Qt-5\5.12.1\msvc2017\include\QtCore -ItestQt\mocs -IC:\VulkanSDK\1.0.51.0\include -IC:\Programs\Qt-5\5.12.1\msvc2017\mkspecs\win32-msvc -FobuildTestQt.debug\ @C:\Users\rjl\AppData\Local\Temp\nm4C7A.tmp

I simplified my code just a bit. I removed as many of the LOG4PLUS_TEXT() macro calls as I could.

void
initLogging() {
    log4cplus::initialize();
    // LogLog::getLogLog()->setInternalDebugging(true);
    Logger root = Logger::getRoot();
    try {
        log4cplus::tstring log4cplusfName(LOG4CPLUS_TEXT("clientServices/resource/log4cplus.properties"));

        PropertyConfigurator::doConfigure(log4cplusfName);
        Logger fileCat = Logger::getInstance(LOG4CPLUS_TEXT("filelogger"));

        LOG4CPLUS_WARN(root, "Testing....");
        LOG4CPLUS_WARN(root, "Writing messages to log....");
        for (int i = 0; i < 10000; ++i)
            LOG4CPLUS_WARN(fileCat, "This is a WARNING..."
                << i);
    }
    catch (...) {
        tcout << "Exception..." << endl;
        LOG4CPLUS_FATAL(root, "Exception occured...");
    }
}

Now the link errors:

1>  link /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /SUBSYSTEM:CONSOLE "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" /MANIFEST:embed /OUT:binTestQt.debug\testQt.exe @C:\Users\rjl\AppData\Local\Temp\nm8298.tmp
1>testQt.obj : error LNK2019: unresolved external symbol "public: static class log4cplus::Logger __cdecl log4cplus::Logger::getInstance(class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > const &)" (?getInstance@Logger@log4cplus@@SA?AV12@ABV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@@Z) referenced in function "void __cdecl initLogging(void)" (?initLogging@@YAXXZ)
1>testQt.obj : error LNK2019: unresolved external symbol "class std::basic_ostringstream<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > & __cdecl log4cplus::detail::get_macro_body_oss(void)" (?get_macro_body_oss@detail@log4cplus@@YAAAV?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@XZ) referenced in function "void __cdecl initLogging(void)" (?initLogging@@YAXXZ)
1>testQt.obj : error LNK2019: unresolved external symbol "void __cdecl log4cplus::detail::macro_forced_log(class log4cplus::Logger const &,int,class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > const &,char const *,int,char const *)" (?macro_forced_log@detail@log4cplus@@YAXABVLogger@2@HABV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@PBDH2@Z) referenced in function "void __cdecl initLogging(void)" (?initLogging@@YAXXZ)
1>testQt.obj : error LNK2019: unresolved external symbol "public: static void __cdecl log4cplus::PropertyConfigurator::doConfigure(class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > const &,class log4cplus::Hierarchy &,unsigned int)" (?doConfigure@PropertyConfigurator@log4cplus@@SAXABV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@AAVHierarchy@2@I@Z) referenced in function "void __cdecl initLogging(void)" (?initLogging@@YAXXZ)
1>testQt.obj : error LNK2001: unresolved external symbol "class std::basic_ostream<wchar_t,struct std::char_traits<wchar_t> > & log4cplus::tcout" (?tcout@log4cplus@@3AAV?$basic_ostream@_WU?$char_traits@_W@std@@@std@@A)
1>binTestQt.debug\testQt.exe : fatal error LNK1120: 5 unresolved externals

The LIBS used:

LIBS          = /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.17763.0\um\x86" /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.17763.0\ucrt\x86" "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.17763.0\ucrt\x86\ucrt.lib" /LIBPATH:C:\Programs\log4cplus-1.2.1\lib C:\Programs\log4cplus-1.2.1\lib\log4cplusSD.lib "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.17763.0\um\x86\GlU32.lib" "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.17763.0\um\x86\AdvAPI32.lib" "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.17763.0\um\x86\ws2_32.lib" "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.17763.0\um\x86\shell32.lib" "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.17763.0\um\x86\User32.lib" /LIBPATH:C:\Programs\Qt-5\5.12.1\msvc2017\lib C:\Programs\Qt-5\5.12.1\msvc2017\lib\Qt5Widgetsd.lib C:\Programs\Qt-5\5.12.1\msvc2017\lib\Qt5Guid.lib C:\Programs\Qt-5\5.12.1\msvc2017\lib\Qt5Cored.lib   

I think this has something to do with the use of the UNICODE compile-time macro and the definition of the LOG4PLUS_TEXT macro. I see the Log4Plus code is NOT compiled with the UNICODE macro. I'm going to pursue that for a bit today....

wilx commented 5 years ago

Your LIBS shows log4cplusSD.lib which is the non-wchar_t variant of log4cplus but your code is compiling with the wchar_t API of log4cplus. You need to use matching log4cplus static library. It would have USD suffix for wchar_t-aware static debugging binary.

retiredracer commented 5 years ago

Thanks again for the quick response.

Sorry, I'm working on two projects here so I only get a few hours a day to work on this project. Hence my slow response....

Here is the compile line for my code now:

    cl -c -nologo -Zc:wchar_t- -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus /MP4 -Zi -MDd -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 -EHsc /FdbuildTestQt.debug\testQt.vc.pdb -DUNICODE -D_UNICODE -DWIN32 -D_ENABLE_EXTENDED_ALIGNED_STORAGE -DLOG4CPLUS_STATIC -DBUILD_DLL -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I. -IC:\Programs\log4cplus-1.2.1\include -I..\model\src -I../flowEngine/src -I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um" -I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt" -I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\shared" -IC:\Programs\Qt-5\5.12.1\msvc2017\include -IC:\Programs\Qt-5\5.12.1\msvc2017\include\QtWidgets -IC:\Programs\Qt-5\5.12.1\msvc2017\include\QtGui -IC:\Programs\Qt-5\5.12.1\msvc2017\include\QtANGLE -IC:\Programs\Qt-5\5.12.1\msvc2017\include\QtCore -ItestQt\mocs -IC:\VulkanSDK\1.0.51.0\include -IC:\Programs\Qt-5\5.12.1\msvc2017\mkspecs\win32-msvc -FobuildTestQt.debug\ @C:\Users\rjl\AppData\Local\Temp\nm330.tmp

Here is the compile line for the Log4Cplus (SD) project:

/MP /GS /analyze- /W3 /Gy /Zc:wchar_t- /I"..\include" /Zi /Gm- /Od /sdl /Fd"C:\cygwin64\home\rjl\projects\log4cplus-1.2.1.nowchar\msvc10\Win32\bin.Debug\log4cplusSD.c.pdb" /Zc:inline /fp:precise /D "LOG4CPLUS_STATIC" /D "_DEBUG" /D "DEBUG" /D "WIN32" /D "_WIN32_WINNT=0x0501" /D "WINVER=0x0501" /D "NTDDI_VERSION=0x05010200" /D "INSIDE_LOG4CPLUS" /D "_SCL_SECURE_NO_DEPRECATE" /D "_CRT_SECURE_NO_DEPRECATE" /D "_CRT_SECURE_NO_WARNINGS" /D "_WINSOCK_DEPRECATED_NO_WARNINGS" /D "_MBCS" /errorReport:prompt /GF /WX- /Zc:forScope /RTC1 /Gd /Oy- /MDd /FC /Fa"C:\cygwin64\home\rjl\projects\log4cplus-1.2.1.nowchar\msvc10\Win32\obj.log4cplusS.Debug\" /EHsc /nologo /Fo"C:\cygwin64\home\rjl\projects\log4cplus-1.2.1.nowchar\msvc10\Win32\obj.log4cplusS.Debug\" /Fp"C:\cygwin64\home\rjl\projects\log4cplus-1.2.1.nowchar\msvc10\Win32\obj.log4cplusS.Debug\log4cplusS.pch" /diagnostics:classic 

Here is the linker output:

    link /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /SUBSYSTEM:CONSOLE "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" /MANIFEST:embed /OUT:binTestQt.debug\testQt.exe @C:\Users\rjl\AppData\Local\Temp\nm13EB.tmp
testQt.obj : error LNK2019: unresolved external symbol "public: static class log4cplus::Logger __cdecl log4cplus::Logger::getInstance(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)" (?getInstance@Logger@log4cplus@@SA?AV12@ABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@Z) referenced in function "void __cdecl initLogging(void)" (?initLogging@@YAXXZ)
testQt.obj : error LNK2019: unresolved external symbol "class std::basic_ostringstream<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > & __cdecl log4cplus::detail::get_macro_body_oss(void)" (?get_macro_body_oss@detail@log4cplus@@YAAAV?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@XZ) referenced in function "void __cdecl initLogging(void)" (?initLogging@@YAXXZ)
testQt.obj : error LNK2019: unresolved external symbol "void __cdecl log4cplus::detail::macro_forced_log(class log4cplus::Logger const &,int,class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &,char const *,int,char const *)" (?macro_forced_log@detail@log4cplus@@YAXABVLogger@2@HABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@PBDH2@Z) referenced in function "void __cdecl initLogging(void)" (?initLogging@@YAXXZ)
testQt.obj : error LNK2019: unresolved external symbol "public: static void __cdecl log4cplus::PropertyConfigurator::doConfigure(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &,class log4cplus::Hierarchy &,unsigned int)" (?doConfigure@PropertyConfigurator@log4cplus@@SAXABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@AAVHierarchy@2@I@Z) referenced in function "void __cdecl initLogging(void)" (?initLogging@@YAXXZ)
testQt.obj : error LNK2001: unresolved external symbol "class std::basic_ostream<unsigned short,struct std::char_traits<unsigned short> > & log4cplus::tcout" (?tcout@log4cplus@@3AAV?$basic_ostream@GU?$char_traits@G@std@@@std@@A)
binTestQt.debug\testQt.exe : fatal error LNK1120: 5 unresolved externals

I still think the issue is the UNICODE compile-time option. I'm going to pursue that more now.

retiredracer commented 5 years ago

Definitely a character set (UNICODE) issue.

My code is built with UNICODE but the Log4Cplus was not. I changed the Log4Cplus to specify the UNICODE character set and Boom! It linked.

I also tried both the -Zc:wchar_t and -Zc:wchar_t- options and, if consistently set in both projects, also linked (if UNICODE is also consistently set in both projects).

So, both the -Zc:wchar_t option and character set option need to be consistently set in both projects (I should have known that).

Since I was using UNICODE character set and -Zc:wchar_t option in my project, I'm going to build and use Log4Cplus with those options, as well.

Thanks much for your time on this issue. r