Opened 15 years ago
Closed 15 years ago
#995 closed Bugs (fixed)
'multiply defined symbols' when including <boost/filesystem.hpp> in different source files
Reported by: | anonymous | Owned by: | Beman Dawes |
---|---|---|---|
Milestone: | Component: | filesystem | |
Version: | Boost 1.34.0 | Severity: | Problem |
Keywords: | Cc: |
Description
When <boost/filesystem.hpp> is included in different source files, the linker complains about 'multiply defined symbols'
Attached: two source files that reproduce the error when compiled and linked in the same project.
boost-1.34.0 MSVC 7.0
test2.obj : error LNK2005: "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl boost::filesystem::extension(class boost::filesystem::basic_path<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct boost::filesystem::path_traits> const &)" (?extension@filesystem@boost@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV?$basic_path@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@Upath_traits@filesystem@boost@@@12@@Z) already defined in test.obj test2.obj : error LNK2005: "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl boost::filesystem::basename(class boost::filesystem::basic_path<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct boost::filesystem::path_traits> const &)" (?basename@filesystem@boost@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV?$basic_path@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@Upath_traits@filesystem@boost@@@12@@Z) already defined in test.obj Release/test.exe : fatal error LNK1169: one or more multiply defined symbols found
Attachments (2)
Change History (9)
by , 15 years ago
comment:1 by , 15 years ago
Workaround (works for MSVC 7.0):
add "/force:multiple" to advanced linker options
comment:2 by , 15 years ago
There is an "inline" missing in filesystem/convenience.hpp
# define BOOST_FS_FUNC_STRING std::string
should be
# define BOOST_FS_FUNC_STRING inline std::string
comment:3 by , 15 years ago
Owner: | set to |
---|
comment:5 by , 15 years ago
This problem exists with mingw/gcc too. But the suggested workaround works.
comment:5 by , 15 years ago
This problem exists with mingw/gcc too. But the suggestes workaround works.
comment:7 by , 15 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
first file