Library Duplicates in Visual Studio with NuGet

#1

I’ve downloaded some external libraries using vcpkg, and exported them as a NuGet package for easy import into Visual Studio 2017. This works well outside of openframeworks (especially for libraries with many dependencies such as PCL), but when using with openframeworks, I get conflict errors from duplicate libraries.

Similar to this post, these issues are coming primarily from boost and openssl. Is there any way to somehow unlink the openframeworks version of these libraries so the NuGet version doesn’t conflict? Or the other way around?

Errors currently look something like:

Severity Code Description Project File Line Suppression State Error LNK2005 "void __cdecl boost::filesystem::path_traits::convert(char const *,char const *,class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > &,class std::codecvt<wchar_t,char,struct _Mbstatet> const &)" (?convert@path_traits@filesystem@boost@@YAXPEBD0AEAV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@AEBV?$codecvt@_WDU_Mbstatet@@@5@@Z) already defined in boost_filesystem-vc140-mt.lib(boost_filesystem-vc141-mt-x64-1_70.dll)

Severity Code Description Project File Line Suppression State Error LNK2005 SSL_CTX_check_private_key already defined in ssleay32.lib(SSLEAY32.dll)

etc. etc.

Many thanks in advance for any suggestions!

#2

Well, I haven’t figured out how to just use a NuGet package directly (which would be great!), but I’ll leave a note of my clumsy workaround here for those making use of vcpkg to manage many dependencies (without vcpkg integrate, which definitely breaks everything).

  1. Install all necessary external packages in your vcpkg directory as usual, letting it figure out what extra stuff you need (can take forever and use lots of space).

  2. Under your project properties in VS, add your vcpkg include directory (i.e. C:\blah\vcpkg\installed\x64-windows\include) to your “Additional Include Directories” under C/C++>General>Additional Include Directories

  3. Under Linker>Additional Library Directories, add the location of your vcpkg libsC:\blah\vcpkg\installed\x64-windows\lib

  4. Under Linker>Input>Additional Dependencies, add all of the lib filenames in the folder from the previous step. As in my case there are too many for copy and pasting, I used this trick to generate a text file of all the names in the folder. Remove any duplicate lib names that are already in OF (in my case, boost_filesystem-vc140.mt.lib etc.).

  5. Under Configuration Properties>Debugging>Environment, add the path to your vcpkg bin folder, i.e. C:\blah\vcpkg\installed\x64-windows\bin so VS can find .dlls

  6. Profit! Or, at least get out of dll purgatory for a few moments…