[log] Problem with Unicode and linker error

I downloaded Boost.Log from http://www.torjo.com/code/log2.zip to give it a try but ran into two problems immediately (with VC++ 9.0 on Windows XP): * In the (old?) documentation at http://www.torjo.com/log2/doc/html/miscelaneous.html#misc_unicode a macro called BOOST_LOG_DONOT_USE_WCHAR_T is mentioned which can be defined on Windows to use char-based classes instead of wchar_t-based classes. This macro doesn't seem to work though. I couldn't find any other macro I might be able to define to use char-based classes if UNICODE is defined? * The linker is trying to find a library called boost_log-vc90-mt-gd-1_34_1.lib while the filename is really libboost_log-vc90-mt-gd-1_34_1.lib. I renamed the file but got then a linker error (unresolved external symbol "... boost::logging::find_log_by_name(...)"). My code consists only of BOOST_DECLARE_LOG and BOOST_DEFINE_LOG though (thus I would expect I can't make much wrong here :)? Anyone can help? Or is the zip archive I downloaded actually the latest code? Boris

On Thu, 24 Apr 2008 01:19:24 +0200, Boris <boriss@web.de> wrote:
[...]* The linker is trying to find a library called boost_log-vc90-mt-gd-1_34_1.lib while the filename is really libboost_log-vc90-mt-gd-1_34_1.lib. I renamed the file but got then a linker error (unresolved external symbol "... boost::logging::find_log_by_name(...)"). My code consists only of BOOST_DECLARE_LOG and BOOST_DEFINE_LOG though (thus I would expect I can't make much wrong here :)?
As far as I understand meanwhile the linker is trying to link against a DLL (that's why it's looking for boost_log-vc90-mt-gd-1_34_1.lib) but there has no DLL been built when I ran bjam. I'd prefer to link statically but would be happy if anyone could tell me how to invoke bjam to create a DLL for (Boost.)Log. I found the directory bin.v2\libs\log\build\msvc-9.0\debug\link-static\threading-multi but there is no DLL indeed. Or doesn't (Boost.)Log create DLLs yet/currently? Boris

On Thu, 24 Apr 2008 15:34:40 +0200, Boris <boriss@web.de> wrote:
On Thu, 24 Apr 2008 01:19:24 +0200, Boris <boriss@web.de> wrote:
[...]* The linker is trying to find a library called boost_log-vc90-mt-gd-1_34_1.lib while the filename is really libboost_log-vc90-mt-gd-1_34_1.lib. I renamed the file but got then a linker error (unresolved external symbol "... boost::logging::find_log_by_name(...)"). My code consists only of BOOST_DECLARE_LOG and BOOST_DEFINE_LOG though (thus I would expect I can't make much wrong here :)?
As far as I understand meanwhile the linker is trying to link against a DLL (that's why it's looking for boost_log-vc90-mt-gd-1_34_1.lib) but there has no DLL been built when I ran bjam. I'd prefer to link statically but would be happy if anyone could tell me how to invoke bjam to create a DLL for (Boost.)Log. I found the directory bin.v2\libs\log\build\msvc-9.0\debug\link-static\threading-multi but there is no DLL indeed. Or doesn't (Boost.)Log create DLLs yet/currently?
After looking around in the source code of (Boost.)Log I found this: #if defined(_DLL) || defined(_USRDLL) #ifndef BOOST_LOG_DYN_LINK #define BOOST_LOG_DYN_LINK #endif #endif If a DLL is created in Visual Studio _DLL or _USRDLL is defined by default - which means the library is dynamically linked. As no DLL for (Boost.)Log is created though linking obviously fails. After removing the code above the library is statically linked. I get then the following linker error but that's something I try to work on next: error LNK2019: unresolved external symbol "class boost::shared_ptr<struct boost::logging::logger_impl> __cdecl boost::logging::find_log_by_name(struct boost::logging::default_log_manager &,class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > const &)" (?find_log_by_name@logging@boost@@YA?AV?$shared_ptr@Ulogger_impl@logging@boost@@@2@AAUdefault_log_manager@12@ABV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@@Z) referenced in function "public: __thiscall boost::logging::logger::logger(class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > const &)" (??0logger@logging@boost@@QAE@ABV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@@Z) Boris

On Thu, 24 Apr 2008 16:21:29 +0200, Boris <boriss@web.de> wrote:
[...]error LNK2019: unresolved external symbol "class boost::shared_ptr<struct boost::logging::logger_impl> __cdecl boost::logging::find_log_by_name(struct boost::logging::default_log_manager &,class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > const &)" (?find_log_by_name@logging@boost@@YA?AV?$shared_ptr@Ulogger_impl@logging@boost@@@2@AAUdefault_log_manager@12@ABV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@@Z) referenced in function "public: __thiscall boost::logging::logger::logger(class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > const &)" (??0logger@logging@boost@@QAE@ABV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@@Z)
The linker error is also a Unicode-related problem: As Boost.Log is not a header-only library it's important to make sure that the library is built with the Unicode configuration which is used later in the projects. By default it seems like that Boost.Log is built for char-based strings. If you create then a project in VC++ where wchar_t-based strings are used you'll get a linker error. The obvious fix would be to make the library header-only. Otherwise you need to go back and build a new version of Boost.Log for every project you use a different string type in. Boris

Boris wrote:
On Thu, 24 Apr 2008 01:19:24 +0200, Boris <boriss@web.de> wrote:
[...]* The linker is trying to find a library called boost_log-vc90-mt-gd-1_34_1.lib while the filename is really libboost_log-vc90-mt-gd-1_34_1.lib. I renamed the file but got then a linker error (unresolved external symbol "... boost::logging::find_log_by_name(...)"). My code consists only of BOOST_DECLARE_LOG and BOOST_DEFINE_LOG though (thus I would expect I can't make much wrong here :)?
As far as I understand meanwhile the linker is trying to link against a DLL (that's why it's looking for boost_log-vc90-mt-gd-1_34_1.lib) but there has no DLL been built when I ran bjam. I'd prefer to link statically but would be happy if anyone could tell me how to invoke bjam to create a DLL for (Boost.)Log. I found the directory bin.v2\libs\log\build\msvc-9.0\debug\link-static\threading-multi but there is no DLL indeed. Or doesn't (Boost.)Log create DLLs yet/currently?
This is VERY strange. Could you send me a snippet of the code. Just as a side-note - the library is header-only, so it doesn't make sense to try to link to a lib. Best, John
Boris
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
-- http://John.Torjo.com -- C++ expert http://blog.torjo.com ... call me only if you want things done right

On Tue, 29 Apr 2008 09:48:49 +0200, John Torjo <john.groups@torjo.com> wrote: Hi John,
[...]
As far as I understand meanwhile the linker is trying to link against a DLL (that's why it's looking for boost_log-vc90-mt-gd-1_34_1.lib) but there has no DLL been built when I ran bjam. I'd prefer to link statically but would be happy if anyone could tell me how to invoke bjam to create a DLL for (Boost.)Log. I found the directory bin.v2\libs\log\build\msvc-9.0\debug\link-static\threading-multi but there is no DLL indeed. Or doesn't (Boost.)Log create DLLs yet/currently?
This is VERY strange. Could you send me a snippet of the code. Just as a side-note - the library is header-only, so it doesn't make sense to try to link to a lib.
the library is header-only?! I downloaded the library from http://www.torjo.com/code/log2.zip - is this an old version which maybe was not yet header-only? Boris

the library is header-only?! I downloaded the library from http://www.torjo.com/code/log2.zip - is this an old version which maybe was not yet header-only?
Nope, you got the right one :) And if you go to libs/logging/src, you'll see there's just one file called dummy.txt. So, that's why I'm puzzled by your error - I don't link to any library or dll. From your error, it seems you're trying to use v1 (version one of the library) and v2 (current version of the library). The old version did contain source files, but th enew one doesn't. Best, John
Boris
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
-- http://John.Torjo.com -- C++ expert http://blog.torjo.com ... call me only if you want things done right
participants (2)
-
Boris
-
John Torjo