appleseedhq / appleseed

A modern open source rendering engine for animation and visual effects
https://appleseedhq.net/
MIT License
2.2k stars 329 forks source link

Linking to boost 1.61 with MSVC 2013 64-bit issue #1408

Open boberfly opened 7 years ago

boberfly commented 7 years ago

Hi all, while porting Gaffer to Windows I've hit a small snag compiling Appleseed 1.6.0-beta from gafferDependencies, my own branch: gafferDependencies which is based off of the bash scripts for Linux/macOS...

 appleseed.dir\Release\/renderer/utility/testutils.cpp.obj
boost_date_time-vc120-mt-1_61.lib(boost_date_time-vc120-mt-1_61.dll) : error LNK2005: "public: __cdecl boost::gregorian
::greg_month::greg_month(unsigned short)" (??0greg_month@gregorian@boost@@QEAA@G@Z) already defined in benchmark_cache.
obj [C:\Users\Alex\dev\dependencies\appleseed-1.6.0-beta\build\src\appleseed\appleseed.vcxproj]
boost_filesystem-vc120-mt-1_61.lib(boost_filesystem-vc120-mt-1_61.dll) : error LNK2005: "public: __cdecl boost::filesys
tem::path::path(class boost::filesystem::path const &)" (??0path@filesystem@boost@@QEAA@AEBV012@@Z) already defined in
test_path.obj [C:\Users\Alex\dev\dependencies\appleseed-1.6.0-beta\build\src\appleseed\appleseed.vcxproj]
boost_filesystem-vc120-mt-1_61.lib(boost_filesystem-vc120-mt-1_61.dll) : error LNK2005: "public: class boost::filesyste
m::path & __cdecl boost::filesystem::path::operator=(class boost::filesystem::path &&)" (??4path@filesystem@boost@@QEAA
AEAV012@$$QEAV012@@Z) already defined in searchpaths.obj [C:\Users\Alex\dev\dependencies\appleseed-1.6.0-beta\build\src
\appleseed\appleseed.vcxproj]
boost_filesystem-vc120-mt-1_61.lib(boost_filesystem-vc120-mt-1_61.dll) : error LNK2005: "public: class boost::filesyste
m::path & __cdecl boost::filesystem::path::operator=(class boost::filesystem::path const &)" (??4path@filesystem@boost@
@QEAAAEAV012@AEBV012@@Z) already defined in searchpaths.obj [C:\Users\Alex\dev\dependencies\appleseed-1.6.0-beta\build\
src\appleseed\appleseed.vcxproj]
boost_filesystem-vc120-mt-1_61.lib(boost_filesystem-vc120-mt-1_61.dll) : error LNK2005: "public: void __cdecl boost::fi
lesystem::path::clear(void)" (?clear@path@filesystem@boost@@QEAAXXZ) already defined in searchpaths.obj [C:\Users\Alex\
dev\dependencies\appleseed-1.6.0-beta\build\src\appleseed\appleseed.vcxproj]
boost_filesystem-vc120-mt-1_61.lib(boost_filesystem-vc120-mt-1_61.dll) : error LNK2005: "public: class std::basic_strin
g<char,struct std::char_traits<char>,class std::allocator<char> > const __cdecl boost::filesystem::path::string(void)co
nst " (?string@path@filesystem@boost@@QEBA?BV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) already d
efined in genericimagefilereader.obj [C:\Users\Alex\dev\dependencies\appleseed-1.6.0-beta\build\src\appleseed\appleseed
.vcxproj]
boost_filesystem-vc120-mt-1_61.lib(boost_filesystem-vc120-mt-1_61.dll) : error LNK2005: "public: bool __cdecl boost::fi
lesystem::path::has_root_directory(void)const " (?has_root_directory@path@filesystem@boost@@QEBA_NXZ) already defined i
n searchpaths.obj [C:\Users\Alex\dev\dependencies\appleseed-1.6.0-beta\build\src\appleseed\appleseed.vcxproj]
boost_filesystem-vc120-mt-1_61.lib(boost_filesystem-vc120-mt-1_61.dll) : error LNK2005: "public: __cdecl boost::filesys
tem::path::~path(void)" (??1path@filesystem@boost@@QEAA@XZ) already defined in genericimagefilereader.obj [C:\Users\Ale
x\dev\dependencies\appleseed-1.6.0-beta\build\src\appleseed\appleseed.vcxproj]
boost_thread-vc120-mt-1_61.lib(boost_thread-vc120-mt-1_61.dll) : error LNK2005: "public: __cdecl boost::detail::thread_
data_base::thread_data_base(void)" (??0thread_data_base@detail@boost@@QEAA@XZ) already defined in workerthread.obj [C:\
Users\Alex\dev\dependencies\appleseed-1.6.0-beta\build\src\appleseed\appleseed.vcxproj]
boost_thread-vc120-mt-1_61.lib(boost_thread-vc120-mt-1_61.dll) : error LNK2005: "private: void __cdecl boost::thread::s
tart_thread(void)" (?start_thread@thread@boost@@AEAAXXZ) already defined in workerthread.obj [C:\Users\Alex\dev\depende
ncies\appleseed-1.6.0-beta\build\src\appleseed\appleseed.vcxproj]
boost_thread-vc120-mt-1_61.lib(boost_thread-vc120-mt-1_61.dll) : error LNK2005: "public: __cdecl boost::thread::~thread
(void)" (??1thread@boost@@QEAA@XZ) already defined in workerthread.obj [C:\Users\Alex\dev\dependencies\appleseed-1.6.0-
beta\build\src\appleseed\appleseed.vcxproj]
boost_thread-vc120-mt-1_61.lib(boost_thread-vc120-mt-1_61.dll) : error LNK2005: "public: void __cdecl boost::thread::jo
in(void)" (?join@thread@boost@@QEAAXXZ) already defined in workerthread.obj [C:\Users\Alex\dev\dependencies\appleseed-1
.6.0-beta\build\src\appleseed\appleseed.vcxproj]
boost_thread-vc120-mt-1_61.lib(boost_thread-vc120-mt-1_61.dll) : error LNK2005: "private: void __cdecl boost::detail::w
in32::handle_manager::cleanup(void)" (?cleanup@handle_manager@win32@detail@boost@@AEAAXXZ) already defined in thread.ob
j [C:\Users\Alex\dev\dependencies\appleseed-1.6.0-beta\build\src\appleseed\appleseed.vcxproj]
LINK : fatal error LNK1104: cannot open file 'libboost_atomic-vc120-mt-1_61.lib' [C:\Users\Alex\dev\dependencies\apples
eed-1.6.0-beta\build\src\appleseed\appleseed.vcxproj]

Just curious if there's something trivial that I'm missing here, you can check in my repository on the build script that I've written here

Thanks all.

dictoon commented 7 years ago

I noticed you're building appleseed with USE_STATIC_BOOST=OFF. I usually build it with USE_STATIC_BOOST=ON. I can understand that in the context of Gaffer, you may want to build appleseed against dynamic Boost libraries, although I don't think it would make much differences.

Here are the official build instructions on Windows, just in case you would have missed them: https://github.com/appleseedhq/appleseed/wiki/Building-appleseed-on-Windows

It looks like the *.obj files contain definitions for many Boost symbols, a bit like if it had been built against static Boost libraries.

boberfly commented 7 years ago

Yep I kind of don't want to static link as much as possible, but unfortunately I've needed to do this with OIIO/OSL so far. Does Appleseed not dynamic link in the context of the Maya plugin to the ones that come with Maya?

boberfly commented 7 years ago

I had a bit of time to look into this again. In the CMakeLists.txt of Appleseed adding a particular definition seems to work for me:

if (USE_STATIC_BOOST)
    set (Boost_USE_STATIC_LIBS TRUE)
else ()
    add_definitions(-DBOOST_ALL_DYN_LINK)
endif ()

I now have a jumble of OIIO/image lib-related linker issues to look into now... :)

est77 commented 7 years ago

We don't have a Windows build of the Maya plugin yet. As far as I know, the only lib that's included in Maya that we (optionally) link too is OpenColorIO. Maya does not include OpenImageIO or OSL. On linux, I'm dynamic linking all libs for now.

dictoon commented 7 years ago

@boberfly About BOOST_ALL_DYN_LINK: if it turns out to work fine at the end, then we'll be happy to add it to our CMake setup. Please let us know how it turns out! We also gladly accept PRs :)

boberfly commented 7 years ago

@dictoon @est77 cheers for the info. Yep I can do some PRs once I discover all the dynamic link flag jumbles, there's a few I think related to dynamic OpenEXR also, need to fix OSL linking to OIIO dynamic first I think...

boberfly commented 7 years ago

Another one I found: BOOST_PYTHON_STATIC_LIB

I've removed this line and made it:

if (USE_STATIC_BOOST)
    set (Boost_USE_STATIC_LIBS TRUE)
    add_definitions(-DBOOST_PYTHON_STATIC_LIB) # link statically against Boost.Python
else ()
    add_definitions(-DBOOST_ALL_DYN_LINK)
endif ()

I'd like to get around to making PRs eventually, there's also one for dynamic OpenEXR: -DOPENEXR_DLL

Cheers...

dictoon commented 7 years ago

Good find! Thanks for doing this ungrateful work... Will definitely appreciate a PR at the end since I'll likely have to go through the same pain when building appleseed-maya on Windows...

dictoon commented 6 years ago

FYI, we're now building and shipping appleseed-maya for Windows. We're linking statically against Boost.

@boberfly, is this issue still relevant?

boberfly commented 6 years ago

@dictoon yep! https://github.com/appleseedhq/appleseed/pull/2075 Cheers, yeah I just got into building Gaffer for Windows again and saw that we are applying the patch to the tarball as part of the build process still.