Opened 14 years ago

Closed 13 years ago

Last modified 12 years ago

#2919 closed Bugs (fixed)

Bcp.exe won't compile

Reported by: seppi2112@… Owned by: Douglas Gregor
Milestone: Boost 1.39.0 Component: CMake
Version: Boost 1.39.0 Severity: Problem
Keywords: regex Cc:

Description

Compiling the boost_1_38_0 package in VC9 with Python 2.6. Everything works fine until the compiler gets to the BCP project and I get 10 linking errors. I'm completely new to Boost so the problem is probably on my end, but I have no idea how to resolve this. Any ideas?

Error message follows:


Linking... libboost_regex-vc90-mt-1_38.lib(w32_regex_traits.obj) : error LNK2005: "void cdecl boost::re_detail::free_module(void *)" (?free_module@re_detail@boost@@YAXPAX@Z) already defined in libboost_regex-vc90-mt-gd-1_38.lib(w32_regex_traits.obj)

libboost_regex-vc90-mt-1_38.lib(w32_regex_traits.obj) : error LNK2005: "private: void thiscall boost::re_detail::w32_regex_traits_char_layer<char>::init(void)" (?init@?$w32_regex_traits_char_layer@D@re_detail@boost@@AAEXXZ) already defined in libboost_regex-vc90-mt-gd-1_38.lib(w32_regex_traits.obj)

libboost_regex-vc90-mt-1_38.lib(regex_traits_defaults.obj) : error LNK2005: "char const * * boost::re_detail::def_coll_names" (?def_coll_names@re_detail@boost@@3PAPBDA) already defined in libboost_regex-vc90-mt-gd-1_38.lib(regex_traits_defaults.obj)

libboost_regex-vc90-mt-1_38.lib(regex_traits_defaults.obj) : error LNK2005: "char const * * boost::re_detail::def_multi_coll" (?def_multi_coll@re_detail@boost@@3PAPBDA) already defined in libboost_regex-vc90-mt-gd-1_38.lib(regex_traits_defaults.obj)

libboost_regex-vc90-mt-1_38.lib(regex.obj) : error LNK2005: "public: thiscall boost::regex_error::regex_error(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,enum boost::regex_constants::error_type,int)" (??0regex_error@boost@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@W4error_type@regex_constants@1@H@Z) already defined in libboost_regex-vc90-mt-gd-1_38.lib(regex.obj)

libboost_regex-vc90-mt-1_38.lib(regex.obj) : error LNK2005: "public: thiscall boost::regex_error::regex_error(enum boost::regex_constants::error_type)" (??0regex_error@boost@@QAE@W4error_type@regex_constants@1@@Z) already defined in libboost_regex-vc90-mt-gd-1_38.lib(regex.obj)

libboost_regex-vc90-mt-1_38.lib(regex.obj) : error LNK2005: "public: virtual thiscall boost::regex_error::~regex_error(void)" (??1regex_error@boost@@UAE@XZ) already defined in libboost_regex-vc90-mt-gd-1_38.lib(regex.obj)

libboost_regex-vc90-mt-1_38.lib(regex.obj) : error LNK2005: "public: void thiscall boost::regex_error::raise(void)const " (?raise@regex_error@boost@@QBEXXZ) already defined in libboost_regex-vc90-mt-gd-1_38.lib(regex.obj)

libboost_regex-vc90-mt-1_38.lib(regex.obj) : error LNK2005: "struct boost::re_detail::mem_block_cache boost::re_detail::block_cache" (?block_cache@re_detail@boost@@3Umem_block_cache@12@A) already defined in libboost_regex-vc90-mt-gd-1_38.lib(regex.obj) LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library

C:\boost_1_38_0\bin\Debug\bcp.exe : fatal error LNK1169: one or more multiply defined symbols found Build log was saved at "file://c:\boost_1_38_0\tools\bcp\bcp.dir\Debug\BuildLog.htm" bcp - 10 error(s), 1 warning(s)

Change History (16)

comment:1 by Steven Watanabe, 14 years ago

I have no idea where the project files that you are using come from, but you probably need to remove the boost_regex library from the linker and let automatic linking work.

comment:2 by Seppi2112@…, 14 years ago

I tried adding /force:multiple to the command line and the redefined error changed to "Cannot open include file: 'boost/shared_ptr.hpp' and 'boost/regex.hpp'." Grr. I'm going to just clean this whole project and try and CMAKE it again... maybe I had a library setting wrong.

comment:3 by Steven Watanabe, 14 years ago

Component: Building BoostCMake
Owner: set to Douglas Gregor

Ah. The Cmake build is fairly new and not officially supported.

comment:4 by Seppi2112@…, 14 years ago

That makes sense then. I'm trying to build boost for use in Delta3D and they recommend using CMake... is there a better suggestion?

comment:6 by MBergtholdt, 14 years ago

I have the same problem in VC8 (python 2.5.4), CMake 2.6-p2. The project files are somehow wrong, booth debug and release libraries seem to be linked to bcp.exe. I have this bcp project properties->Linker->Command Line:

/OUT:"D:\work\prima\build\ext-libs\boost_1_38_0\bin\Debug\bcp.exe" /VERSION:0.0 /INCREMENTAL /NOLOGO /MANIFEST /MANIFESTFILE:"bcp.dir\Debug\bcp.exe.intermediate.manifest" /PDB:"D:/work/prima/build/ext-libs/boost_1_38_0/bin/Debug/bcp.pdb" /SUBSYSTEM:CONSOLE /IMPLIB:"D:\work\prima\build\ext-libs\boost_1_38_0\lib\Debug\bcp.lib" /ERRORREPORT:PROMPT kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib ..\..\lib\Debug\libboost_system-vc80-mt-gd-1_38.lib ..\..\lib\Debug\libboost_filesystem-vc80-mt-gd-1_38.lib ..\..\lib\Debug\libboost_prg_exec_monitor-vc80-mt-gd-1_38-s.lib ..\..\lib\Debug\libboost_regex-vc80-mt-gd-1_38.lib ..\..\lib\Debug\libboost_system-vc80-mt-gd-1_38.lib "..\..\lib\debug\libboost_system-vc80-mt-1_38.lib" "..\..\lib\debug\libboost_regex-vc80-mt-1_38.lib" "..\..\lib\debug\libboost_prg_exec_monitor-vc80-mt-1_38-s.lib" "..\..\lib\debug\libboost_filesystem-vc80-mt-1_38.lib"

Also in Linker->Input I find this:

..\..\lib\Debug\libboost_system-vc80-mt-gd-1_38.lib ..\..\lib\Debug\libboost_filesystem-vc80-mt-gd-1_38.lib ..\..\lib\Debug\libboost_prg_exec_monitor-vc80-mt-gd-1_38-s.lib ..\..\lib\Debug\libboost_regex-vc80-mt-gd-1_38.lib

but not the release versions. When I remove these, the Command Line above does not change.

comment:7 by chupeev_av@…, 13 years ago

Component: CMakeregex
Keywords: regex added; BCP removed
Owner: changed from Douglas Gregor to John Maddock
Version: Boost 1.38.0Boost 1.39.0

I have the very same problem compiling 64-bit DLL with hand-written makefile or makefile provided with library in folder $(BOOST_ROOT)\libs\regex\build\vc9.mak. To reproduce this error please try to execute command

nmake /nologo /s /f vc9.mak

from within this catalog.

alexander.

comment:8 by John Maddock, 13 years ago

I don't understand - it works for me.

In any case it's basically impossible to get that error from the regex makefile given that it builds the regex libs, and doesn't use them.

Are you sure you're not invoking one of the CMake generated Makefiles?

John.

PS: The original error messages indicate that two different regex libs are being linked into the same .exe, so whatever the cause this really should be an error.

comment:9 by chupeev_av@…, 13 years ago

Yes, John. I'm quite shure that I got these errors building dynamic library. I'm stuck with this several days but doesn't yet found a workaround. These are messages generated by linker when I invoke

nmake /nologo /s /f vc9.mak

from command line:

link kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /incremental:yes /pdb:"vc90/boost_regex-vc90-mt-gd-1_38.pdb" /debug /out:"vc90/boost_regex-vc90-mt-gd-1_38.dll" /implib:"vc90/boost_regex-vc90-mt-gd-1_38.lib" /LIBPATH:"\lib" vc90/boost_regex-vc90-mt-gd-1_38/c_regex_traits.obj vc90/boost_regex-vc90-mt-gd-1_38/cpp_regex_traits.obj vc90/boost_regex-vc90-mt-gd-1_38/cregex.obj vc90/boost_regex-vc90-mt-gd-1_38/fileiter.obj vc90/boost_regex-vc90-mt-gd-1_38/icu.obj vc90/boost_regex-vc90-mt-gd-1_38/instances.obj vc90/boost_regex-vc90-mt-gd-1_38/posix_api.obj vc90/boost_regex-vc90-mt-gd-1_38/regex.obj vc90/boost_regex-vc90-mt-gd-1_38/regex_debug.obj vc90/boost_regex-vc90-mt-gd-1_38/regex_raw_buffer.obj vc90/boost_regex-vc90-mt-gd-1_38/regex_traits_defaults.obj vc90/boost_regex-vc90-mt-gd-1_38/static_mutex.obj vc90/boost_regex-vc90-mt-gd-1_38/usinstances.obj vc90/boost_regex-vc90-mt-gd-1_38/w32_regex_traits.obj vc90/boost_regex-vc90-mt-gd-1_38/wc_regex_traits.obj vc90/boost_regex-vc90-mt-gd-1_38/wide_posix_api.obj vc90/boost_regex-vc90-mt-gd-1_38/winstances.obj

msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: cdecl std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >::~basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >(void)" (??1?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAA@XZ) already defined in w32_regex_traits.obj msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: cdecl std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)" (??0?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAA@AEBV01@@Z) already defined in w32_regex_traits.obj msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: cdecl std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >(struct std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >::_Has_debug_it)" (??0?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAA@U_Has_debug_it@01@@Z) already defined in w32_regex_traits.obj msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: unsigned int64 cdecl std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >::size(void)const " (?size@?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEBA_KXZ) already defined in w32_regex_traits.obj msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > & cdecl std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >::append(unsigned int64,unsigned short)" (?append@?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAAEAV12@_KG@Z) already defined in w32_regex_traits.obj msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "protected: unsigned short * cdecl std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >::_Myptr(void)" (?_Myptr@?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@IEAAPEAGXZ) already defined in w32_regex_traits.obj msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > & cdecl std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >::erase(unsigned int64,unsigned int64)" (?erase@?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAAEAV12@_K0@Z) already defined in w32_regex_traits.obj msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: cdecl std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >(unsigned short const *,unsigned short const *)" (??0?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAA@PEBG0@Z) already defined in w32_regex_traits.obj msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: cdecl std::_String_val<unsigned short,class std::allocator<unsigned short> >::~_String_val<unsigned short,class std::allocator<unsigned short> >(void)" (??1?$_String_val@GV?$allocator@G@std@@@std@@QEAA@XZ) already defined in w32_regex_traits.obj msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "protected: void cdecl std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >::_Tidy(bool,unsigned int64)" (?_Tidy@?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@IEAAX_N_K@Z) already defined in w32_regex_traits.obj msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "protected: cdecl std::_String_val<unsigned short,class std::allocator<unsigned short> >::_String_val<unsigned short,class std::allocator<unsigned short> >(class std::allocator<unsigned short>)" (??0?$_String_val@GV?$allocator@G@std@@@std@@IEAA@V?$allocator@G@1@@Z) already defined in w32_regex_traits.obj msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: cdecl std::allocator<unsigned short>::allocator<unsigned short>(void)" (??0?$allocator@G@std@@QEAA@XZ) already defined in w32_regex_traits.obj

Creating library vc90/boost_regex-vc90-mt-gd-1_38.lib and object vc90/boost_regex-vc90-mt-gd-1_38.exp

vc90/boost_regex-vc90-mt-gd-1_38.dll : fatal error LNK1169: one or more multiply defined symbols found

These errors prevents creating DLL with 64-bit version of MSVC9.

comment:10 by anonymous, 13 years ago

I found solution for the trouble with LNK2005. This trouble occured if file <boost/regex/config.h> has the following declaration at line 169

extern template class declspec(dllimport) std::basic_string<wchar_t>;

in place of

extern template class declspec(dllimport) std::basic_string<unsigned short>;

This problem doesn't depends whether or not /Zc:wchar_t compiler switch defined. Please take this issue for you information.

alexander.

comment:11 by anonymous, 13 years ago

I still don't follow, that header *does* have:

extern template class declspec(dllimport) std::basic_string<unsigned short>;

already at that line ???

John.

comment:12 by chupeev_av@…, 13 years ago

Yes, this is true. I've checked 7z archive originally downloaded from boost site and it has correct declaration. Probably I changed this line by myself trying to make compiler happy and came into trouble. Sorry about that I wasted your time and hastily reported my problem as bug.

comment:13 by anonymous, 13 years ago

Resolution: worksforme
Status: newclosed

No problem, I like bug reports I can close with no action :-)

Regards, John.

comment:14 by Steven Watanabe, 13 years ago

Component: regexCMake
Resolution: worksforme
Status: closedreopened

Hey. This ticket was originally for a completely different error.

comment:15 by John Maddock, 13 years ago

Owner: changed from John Maddock to Douglas Gregor
Status: reopenednew

comment:16 by troy d. straszheim, 13 years ago

Resolution: fixed
Status: newclosed

I'm inclined to manufacture some reason to bounce it back to somebody else, see how long we can keep up the volley. But alas, bcp builds fine under the current release of alt.boost.cmake.

Note: See TracTickets for help on using tickets.