#603 closed Bugs (Fixed)
regex linking error with VC 7.1
Reported by: | nobody | Owned by: | John Maddock |
---|---|---|---|
Milestone: | Component: | regex | |
Version: | None | Severity: | |
Keywords: | Cc: |
Description
I see this error when linking against libboost_regex-vc71-mt-1_33_1.lib: msvcprt.lib(MSVCP71.dll) : error LNK2005: "public: static unsigned int __cdecl std::char_traits<unsigned short>::length(unsigned short const *)" (?length@?$char_traits@G@std@@SAIPBG@Z) already defined in libboost_regex-vc71-mt-1_33_1.lib(usinstances.obj) libs/regex/src/usinstances.cpp appears to have problems. Steps to reproduce: - Create a console project with VC7.1. - Set Character Set to "Use Unicode Character Set" - Use a Multi-threaded DLL - Link against libboost_regex-vc71-mt-1_33_1.lib - wchar_t should NOT be set as a native type - Use the following code: #include "stdafx.h" #include <string> #include <boost/regex.hpp> int _tmain(int argc, _TCHAR* argv[]) { #if _UNICODE std::wstring strCurLine(L"sdfsdfggg"); std::wstring strMatchExp(L"lsdfkjsflk"); boost::wcmatch Matched; boost::wregex regex(strMatchExp.c_str()); #else std::string strCurLine("sdfsdfggg"); std::string strMatchExp("lsdfkjsflk"); boost::cmatch Matched; boost::regex regex(strMatchExp.c_str()); #endif boost::regex_search(strCurLine.c_str(), Matched, regex); return 0; } There are no linking errors if you build with wchar_t as a native type or build with character set as "Use Mutli-Byte Character Set".
Change History (3)
comment:2 by , 17 years ago
Status: | assigned → closed |
---|
Logged In: YES user_id=14804 Apologies, but ignore everything in my last message: you can work around this quite easily by building the regex lib without /Zc:wchar_t, or by adding the line: template<> _CRTIMP2 std::size_t __cdecl char_traits<unsigned short>::length(unsigned short const*); to the end of the other specializations in usinstances.cpp (this is the fix that's going into cvs any minute now). John Maddock
comment:3 by , 16 years ago
Logged In: YES user_id=1651027 Originator: NO I have taken the fix as it appears in the 1_34 alpha. It does not appear to be working, at least for me in VC8. I get LNK2005 errors: error LNK2005: "public: static unsigned int __cdecl std::char_traits<unsigned short>::length(unsigned short const *)" (?length@?$char_traits@G@std@@SAIPBG@Z) already defined in msvcprtd.lib(MSVCP80D.dll) error LNK2005: "public: __thiscall std::allocator<unsigned short>::allocator<unsigned short>(void)" (??0?$allocator@G@std@@QAE@XZ) already defined in msvcprtd.lib(MSVCP80D.dll) I need to build Unicode, with /Zc:wchar_t- to be compatible with our existing codeset. Perhaps this is a different problem?
Note:
See TracTickets
for help on using tickets.