Cannot link XMPCoreStatic.lib and XMPFilesStatic.lib together due to duplicate symbols.
- Dominant language
- C++
- Stars
- 262
- Forks
- 110
- PR merge metrics
- No merged PRs in 30d
Description
### Expected Behaviour
XMPCoreStatic.lib and XMPFilesStatic.lib can be linked into a single DLL.
### Actual Behaviour
When attempting to link the following errors will be produced:
```
1>XMPCoreStatic.lib(CoreObjectFactoryImpl.obj) : error LNK2005: "public: static class AdobeXMPCore::ICoreObjectFactory_v1 * __cdecl AdobeXMPCore::ICoreObjectFactory_v1::GetCoreObjectFactory(void)" (?GetCoreObjectFactory@ICoreObjectFactory_v1@AdobeXMPCore@@SAPEAV12@XZ) already defined in XMPFilesStatic.lib(ICoreObjectFactory.obj)
1>XMPCoreStatic.lib(CoreObjectFactoryImpl.obj) : error LNK2005: "public: static void __cdecl AdobeXMPCore::ICoreObjectFactory_v1::SetupCoreObjectFactory(void)" (?SetupCoreObjectFactory@ICoreObjectFactory_v1@AdobeXMPCore@@SAXXZ) already defined in XMPFilesStatic.lib(ICoreObjectFactory.obj)
1>XMPCoreStatic.lib(CoreObjectFactoryImpl.obj) : error LNK2005: "public: static void __cdecl AdobeXMPCore::ICoreObjectFactory_v1::DestroyCoreObjectFactory(void)" (?DestroyCoreObjectFactory@ICoreObjectFactory_v1@AdobeXMPCore@@SAXXZ) already defined in XMPFilesStatic.lib(ICoreObjectFactory.obj)
```
### Reproduce Scenario (including but not limited to)
When creating static libraries XMPCoreStatic.lib and XMPFilesStatic.lib, and then attempting to build them into a single module (i.e. a DLL), you will get the above build failures. This is because both static libraries build three identical symbols:
AdobeXMPCore::ICoreObjectFactory_v1::GetCoreObjectFactory
AdobeXMPCore::ICoreObjectFactory_v1::SetupCoreObjectFactory
AdobeXMPCore::ICoreObjectFactory_v1::DestroyCoreObjectFactory
[Here](https://github.com/adobe/XMP-Toolkit-SDK/blob/9f779e85f15c92108f8b911930998a152b209491/XMPCore/source/CoreObjectFactoryImpl.cpp#L184) is where XMPCoreStatic.lib generates its version of these symbols.
[Here](https://github.com/adobe/XMP-Toolkit-SDK/blob/9f779e85f15c92108f8b911930998a152b209491/public/include/XMPCore/source/ICoreObjectFactory.cpp#L68) is where XMPFilesStatic.lib generates its version of these symbols.
#### Steps to Reproduce
1. Build both libraries with default settings (for windows_x64).
2. Link both libraries into a single DLL.
#### Platform and Version
Windows x64, using the latest sources targeting 2023-12.
#### Sample Code that illustrates the problem
N/A
#### Logs taken while reproducing problem
See behavior steps above.
For anybody else experiencing this, you can work-around the issue by specifying /FORCE:MULTIPLE on the linker command line. You will still see the error in the output, but at least it builds.
Contributor guide
Research direction
Start with XMPCore/source/CoreObjectFactoryImpl.cpp around line 184 and public/include/XMPCore/source/ICoreObjectFactory.cpp around line 68, then reproduce the default Windows x64 build and link both static libraries into one DLL. Compare the three duplicate symbols reported by the linker. Done means the DLL links without duplicate-symbol errors or requiring /FORCE:MULTIPLE.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100