NativeInstruments / ni-media

NI Media is a C++ library for reading and writing audio streams.
MIT License
244 stars 34 forks source link

Tests are not building on windows with LINK : fatal error LNK1104: cannot open file 'libboost_filesystem-vc142-mt-x64-1_74.lib' #50

Open yuriy-mochurad opened 3 years ago

yuriy-mochurad commented 3 years ago

Can not build tests in following setup:

Build log looks like:

Build log with not able to find boost library ``` C:\tmp\ni-media\build>cmake --build . --config Release Microsoft (R) Build Engine version 16.6.0+5ff7b0c9e for .NET Framework Copyright (C) Microsoft Corporation. All rights reserved. Checking Build System Building Custom Rule C:/tmp/ni-media/audiostream/CMakeLists.txt iotools.cpp stream_info.cpp istream.cpp ostream.cpp ivectorstream.cpp ifstream.cpp ofstream.cpp ifvectorstream.cpp fstream_info.cpp ifstream_info.cpp ofstream_info.cpp aiff_ofstream.cpp wav_ofstream.cpp Generating Code... audiostream.vcxproj -> C:\tmp\ni-media\build\audiostream\Release\audiostream.lib Building Custom Rule C:/tmp/ni-media/audiostream/test/CMakeLists.txt gtest_main.cpp test_helper.cpp source_test.cpp stream_buffer.test.cpp istream_read_signed_integer.test.cpp istream_read_unsigned_integer.test.cpp istream_read_floating_point.test.cpp ifstream.test.cpp ifstream_robustness.test.cpp ifvectorstream.test.cpp ivectorstream.test.cpp ofstream.test.cpp aiff_ifstream_info.test.cpp aiff_source.test.cpp aiff_sink.test.cpp wav_ifstream_info.test.cpp wav_source.test.cpp wav_ofstream_info.test.cpp wav_sink.test.cpp Generating Code... LINK : fatal error LNK1104: cannot open file 'libboost_filesystem-vc142-mt-x64-1_74.lib' [C:\tmp\ni-media\build\audiostream\test\audiostre am_test.vcxproj] Building Custom Rule C:/tmp/ni-media/audiostream/test/CMakeLists.txt generator.cpp LINK : fatal error LNK1104: cannot open file 'libboost_program_options-vc142-mt-x64-1_74.lib' [C:\tmp\ni-media\build\audiostream\test\gene rator.vcxproj] Building Custom Rule C:/tmp/ni-media/pcm/test/CMakeLists.txt ```

When I explicitly add that lib to link paths I get:

Build log with extra link path ``` C:\tmp\ni-media\build>cmake --build . --config Release Microsoft (R) Build Engine version 16.6.0+5ff7b0c9e for .NET Framework Copyright (C) Microsoft Corporation. All rights reserved. Checking Build System Building Custom Rule C:/tmp/ni-media/audiostream/CMakeLists.txt iotools.cpp stream_info.cpp istream.cpp ostream.cpp ivectorstream.cpp ifstream.cpp ofstream.cpp ifvectorstream.cpp fstream_info.cpp ifstream_info.cpp ofstream_info.cpp aiff_ofstream.cpp wav_ofstream.cpp Generating Code... audiostream.vcxproj -> C:\tmp\ni-media\build\audiostream\Release\audiostream.lib Building Custom Rule C:/tmp/ni-media/audiostream/test/CMakeLists.txt gtest_main.cpp test_helper.cpp source_test.cpp stream_buffer.test.cpp istream_read_signed_integer.test.cpp istream_read_unsigned_integer.test.cpp istream_read_floating_point.test.cpp ifstream.test.cpp ifstream_robustness.test.cpp ifvectorstream.test.cpp ivectorstream.test.cpp ofstream.test.cpp aiff_ifstream_info.test.cpp aiff_source.test.cpp aiff_sink.test.cpp wav_ifstream_info.test.cpp wav_source.test.cpp wav_ofstream_info.test.cpp wav_sink.test.cpp Generating Code... audiostream_test.vcxproj -> C:\tmp\ni-media\build\audiostream\test\Release\audiostream_test.exe Building Custom Rule C:/tmp/ni-media/audiostream/test/CMakeLists.txt generator.cpp libboost_program_options-vc142-mt-x64-1_74.lib(value_semantic.obj) : error LNK2005: "public: __cdecl boost::program_options::error_with_op tion_name::error_with_option_name(class std::basic_string,class std::allocator > const &,class st d::basic_string,class std::allocator > const &,class std::basic_string,class std::allocator > const &,int)" (??0error_with_option_name@program_options@boost@@QEAA@AEBV?$basic_string@DU?$char_tra its@D@std@@V?$allocator@D@2@@std@@00H@Z) already defined in boost_program_options-vc142-mt-x64-1_74.lib(boost_program_options-vc142-mt-x64 -1_74.dll) [C:\tmp\ni-media\build\audiostream\test\generator.vcxproj] libboost_program_options-vc142-mt-x64-1_74.lib(value_semantic.obj) : error LNK2005: "public: __cdecl boost::program_options::invalid_optio n_value::invalid_option_value(class std::basic_string,class std::allocator > const &)" (??0invali d_option_value@program_options@boost@@QEAA@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) already defined in boost_p rogram_options-vc142-mt-x64-1_74.lib(boost_program_options-vc142-mt-x64-1_74.dll) [C:\tmp\ni-media\build\audiostream\test\generator.vcxpro j] libboost_program_options-vc142-mt-x64-1_74.lib(value_semantic.obj) : error LNK2005: "void __cdecl boost::program_options::validators::chec k_first_occurrence(class boost::any const &)" (?check_first_occurrence@validators@program_options@boost@@YAXAEBVany@3@@Z) already defined in boost_program_options-vc142-mt-x64-1_74.lib(boost_program_options-vc142-mt-x64-1_74.dll) [C:\tmp\ni-media\build\audiostream\test\genera tor.vcxproj] libboost_program_options-vc142-mt-x64-1_74.lib(value_semantic.obj) : error LNK2005: "protected: class std::basic_string,class std::allocator > __cdecl boost::program_options::validation_error::get_template(enum boost::program_options:: validation_error::kind_t)" (?get_template@validation_error@program_options@boost@@IEAA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocato r@D@2@@std@@W4kind_t@123@@Z) already defined in boost_program_options-vc142-mt-x64-1_74.lib(boost_program_options-vc142-mt-x64-1_74.dll) [ C:\tmp\ni-media\build\audiostream\test\generator.vcxproj] libboost_program_options-vc142-mt-x64-1_74.lib(value_semantic.obj) : error LNK2005: "private: virtual void __cdecl boost::program_options: :value_semantic_codecvt_helper::parse(class boost::any &,class std::vector,class std::allocator >,class std::allocator,class std::allocator > > > const &,bool)const " (?parse@?$value_semantic_codecvt_helper@D@program_options@boost@@EEBAXAEAVany@3@AEBV?$vector@V?$basic_string@DU ?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@_N@Z) alre ady defined in boost_program_options-vc142-mt-x64-1_74.lib(boost_program_options-vc142-mt-x64-1_74.dll) [C:\tmp\ni-media\build\audiostream \test\generator.vcxproj] libboost_program_options-vc142-mt-x64-1_74.lib(value_semantic.obj) : error LNK2005: "protected: virtual void __cdecl boost::program_option s::error_with_option_name::substitute_placeholders(class std::basic_string,class std::allocator > const &)const " (?substitute_placeholders@error_with_option_name@program_options@boost@@MEBAXAEBV?$basic_string@DU?$char_traits@D@std@@V? $allocator@D@2@@std@@@Z) already defined in boost_program_options-vc142-mt-x64-1_74.lib(boost_program_options-vc142-mt-x64-1_74.dll) [C:\t mp\ni-media\build\audiostream\test\generator.vcxproj] libboost_program_options-vc142-mt-x64-1_74.lib(value_semantic.obj) : error LNK2005: "void __cdecl boost::program_options::validate(class b oost::any &,class std::vector,class std::allocator >,class std::allocator ,class std::allocator > > > const &,class std::basic_string,class std::allocator > *,int)" (?validate@program_options@boost@@YAXAEAVany@2@AEBV?$vector@V?$basic_string@DU? $char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@PEAV?$basic _string@DU?$char_traits@D@std@@V?$allocator@D@2@@5@H@Z) already defined in boost_program_options-vc142-mt-x64-1_74.lib(boost_program_optio ns-vc142-mt-x64-1_74.dll) [C:\tmp\ni-media\build\audiostream\test\generator.vcxproj] libboost_program_options-vc142-mt-x64-1_74.lib(value_semantic.obj) : error LNK2005: "public: virtual char const * __cdecl boost::program_o ptions::error_with_option_name::what(void)const " (?what@error_with_option_name@program_options@boost@@UEBAPEBDXZ) already defined in boos t_program_options-vc142-mt-x64-1_74.lib(boost_program_options-vc142-mt-x64-1_74.dll) [C:\tmp\ni-media\build\audiostream\test\generator.vcx proj] libboost_program_options-vc142-mt-x64-1_74.lib(options_description.obj) : error LNK2005: "public: __cdecl boost::program_options::options_ description::options_description(class std::basic_string,class std::allocator > const &,unsigned int,unsigned int)" (??0options_description@program_options@boost@@QEAA@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@II @Z) already defined in boost_program_options-vc142-mt-x64-1_74.lib(boost_program_options-vc142-mt-x64-1_74.dll) [C:\tmp\ni-media\build\aud iostream\test\generator.vcxproj] libboost_program_options-vc142-mt-x64-1_74.lib(options_description.obj) : error LNK2005: "class std::basic_ostream > & __cdecl boost::program_options::operator<<(class std::basic_ostream > &,class boost::pr ogram_options::options_description const &)" (??6program_options@boost@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AEAV23@AEBVopti ons_description@01@@Z) already defined in boost_program_options-vc142-mt-x64-1_74.lib(boost_program_options-vc142-mt-x64-1_74.dll) [C:\tmp \ni-media\build\audiostream\test\generator.vcxproj] libboost_program_options-vc142-mt-x64-1_74.lib(options_description.obj) : error LNK2005: "public: class boost::program_options::options_de scription_easy_init & __cdecl boost::program_options::options_description_easy_init::operator()(char const *,char const *)" (??Roptions_de scription_easy_init@program_options@boost@@QEAAAEAV012@PEBD0@Z) already defined in boost_program_options-vc142-mt-x64-1_74.lib(boost_progr am_options-vc142-mt-x64-1_74.dll) [C:\tmp\ni-media\build\audiostream\test\generator.vcxproj] libboost_program_options-vc142-mt-x64-1_74.lib(options_description.obj) : error LNK2005: "public: class boost::program_options::options_de scription_easy_init & __cdecl boost::program_options::options_description_easy_init::operator()(char const *,class boost::program_options: :value_semantic const *,char const *)" (??Roptions_description_easy_init@program_options@boost@@QEAAAEAV012@PEBDPEBVvalue_semantic@12@0@Z) already defined in boost_program_options-vc142-mt-x64-1_74.lib(boost_program_options-vc142-mt-x64-1_74.dll) [C:\tmp\ni-media\build\audios tream\test\generator.vcxproj] libboost_program_options-vc142-mt-x64-1_74.lib(options_description.obj) : error LNK2005: "public: class boost::program_options::options_de scription_easy_init __cdecl boost::program_options::options_description::add_options(void)" (?add_options@options_description@program_opti ons@boost@@QEAA?AVoptions_description_easy_init@23@XZ) already defined in boost_program_options-vc142-mt-x64-1_74.lib(boost_program_option s-vc142-mt-x64-1_74.dll) [C:\tmp\ni-media\build\audiostream\test\generator.vcxproj] libboost_program_options-vc142-mt-x64-1_74.lib(convert.obj) : error LNK2005: "class std::basic_string,c lass std::allocator > __cdecl boost::program_options::to_internal(class std::basic_string,class s td::allocator > const &)" (?to_internal@program_options@boost@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEB V34@@Z) already defined in boost_program_options-vc142-mt-x64-1_74.lib(boost_program_options-vc142-mt-x64-1_74.dll) [C:\tmp\ni-media\build \audiostream\test\generator.vcxproj] C:\tmp\ni-media\build\audiostream\test\Release\generator.exe : fatal error LNK1169: one or more multiply defined symbols found [C:\tmp\ni- media\build\audiostream\test\generator.vcxproj] Building Custom Rule C:/tmp/ni-media/pcm/test/CMakeLists.txt ```

Am I doing something wrong here?

P.S.: I also tried to add all dependencies through conan, that ensures that all libraries are being linked but got same result.

marcrambo commented 3 years ago

Sorry for the late reply. Are you still facing this issue?

We have a CI pipeline setup for MSVC2019. I just checked the logs and found the last successful build was using boost 1.73. https://dev.azure.com/mohinda/ni-media/_build/results?buildId=43&view=logs&j=1b5c89fe-70ad-5a27-3200-cdc893585c2c&t=41ca7c80-71a7-5b26-c919-de1799c177ab. The code hasn't changed since then so I would expect this combination to still work.

I just built HEAD locally using VCPKG on Windows with CMake 3.17.0, MSVC2019, boost 1.75.0 and I didn't face any build errors. Could you try using VCPKG? Building boost manually can be error prone, maybe the b2 configuration didn't match the projects compiler settings (MD/MT ... )?