Sharing third party library source cpp with plugin

Hi, I have a third party library that use source cpp that I want use in both project and plugins.

Project
  Plugins
     MyPlugin
         Source
             ThirdPartyCPPSource
  Source
      MyProject
             ThirdPartyCPPSource

I’m familiar with how dll works in c++ normally, but this situation is a bit confusing. I want to include ThirdpartyCPP as a static dependency and I do not want to modify their calls with ThirdPartyCPPSource_API decoration. I also do not want to build it separately as a static lib (which I what I see UE4 engine third party seems to do), I want to include the source in normal build.

Project has MyPlugin as a dependency module, but with visual studio, linker has unresolved errors (I suppose it’s compiling as a dll, and I didn’t decorate with dllexport/dllimport ThirdPartyCPPSource_API).

So I copy the third party library source into the project (as above), and visual studio compiles fine. However, on packaging, linker will complain the third party library is defined multiple times.

So I delete the ThirdPartyCPPSource from the Project, and then it can pack fine!

So the annoying situation is Visual studio is compiling the plugin as a separate dll, but while packing, it doesn’t seem to.

How it is working now

  • Add ThirdPartyCPPSource to both Project and MyPlugin. This satisfy visual studio build but not packing.
  • Delete ThirdPartyCPPSource from Project
  • Pack

A module seems to be the right way to behave like a static library but I will need to modify the ThirdPartyCPPSource with dllimport/dllexport ThirdPartyCPPSource_API decoration. The other way is to make the methods all inline but I rather not modify the library.

What’s the best way to setup this third party library without modifying it?