Bug 15482 – new uuid.d forbids to link statically with other libraries

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
druntime
Product
D
Version
D2
Platform
All
OS
Windows
Creation time
2015-12-29T13:56:22Z
Last change time
2018-01-28T16:33:13Z
Assigned to
No Owner
Creator
Temtaime

Comments

Comment #0 by temtaime — 2015-12-29T13:56:22Z
phobos_x64.lib(uuid.obj) : error LNK2005: CLSID_DirectInput already defined in sdl_x64.lib(SDL_dxjoystick.obj) phobos_x64.lib(uuid.obj) : error LNK2005: CLSID_DirectInputDevice already defined in sdl_x64.lib(SDL_dxjoystick.obj) phobos_x64.lib(uuid.obj) : error LNK2005: GUID_Button already defined in sdl_x64.lib(SDL_dxjoystick.obj) phobos_x64.lib(uuid.obj) : error LNK2005: GUID_ConstantForce already defined in sdl_x64.lib(SDL_dxjoystick.obj) phobos_x64.lib(uuid.obj) : error LNK2005: GUID_CustomForce already defined in sdl_x64.lib(SDL_dxjoystick.obj) phobos_x64.lib(uuid.obj) : error LNK2005: GUID_Damper already defined in sdl_x64.lib(SDL_dxjoystick.obj) phobos_x64.lib(uuid.obj) : error LNK2005: GUID_DEVCLASS_1394 already defined in sdl_x64.lib(SDL_dxjoystick.obj) phobos_x64.lib(uuid.obj) : error LNK2005: GUID_DEVCLASS_1394DEBUG already defined in sdl_x64.lib(SDL_dxjoystick.obj) phobos_x64.lib(uuid.obj) : error LNK2005: GUID_DEVCLASS_61883 already defined in sdl_x64.lib(SDL_dxjoystick.obj) phobos_x64.lib(uuid.obj) : error LNK2005: GUID_DEVCLASS_ADAPTER already defined in sdl_x64.lib(SDL_dxjoystick.obj) phobos_x64.lib(uuid.obj) : error LNK2005: GUID_DEVCLASS_APMSUPPORT already defined in sdl_x64.lib(SDL_dxjoystick.obj) phobos_x64.lib(uuid.obj) : error LNK2005: GUID_DEVCLASS_AVC already defined in sdl_x64.lib(SDL_dxjoystick.obj) phobos_x64.lib(uuid.obj) : error LNK2005: GUID_DEVCLASS_BATTERY already defined in sdl_x64.lib(SDL_dxjoystick.obj) phobos_x64.lib(uuid.obj) : error LNK2005: GUID_DEVCLASS_BLUETOOTH already defined in sdl_x64.lib(SDL_dxjoystick.obj) phobos_x64.lib(uuid.obj) : error LNK2005: GUID_DEVCLASS_CDROM already defined in sdl_x64.lib(SDL_dxjoystick.obj) phobos_x64.lib(uuid.obj) : error LNK2005: GUID_DEVCLASS_COMPUTER already defined in sdl_x64.lib(SDL_dxjoystick.obj) phobos_x64.lib(uuid.obj) : error LNK2005: GUID_DEVCLASS_DECODER already defined in sdl_x64.lib(SDL_dxjoystick.obj) And so on. Why we ever export uuids from uuid.d ?
Comment #1 by code — 2016-01-10T22:39:02Z
I couldn't find any of those symbols in the phobos64.lib from 2.070.0-b1 [¹] or the latest nightly [²]. The name phobos_x64.lib suggests that you've compiled the library yourself. Please provide more details if your problem persists. [¹]: http://downloads.dlang.org/pre-releases/2.x/2.070.0/dmd.2.070.0-b1.windows.7z [²]: https://builds.dawg.eu/dmd-2016-01-10/dmd.master.windows.7z
Comment #2 by dfj1esp02 — 2016-01-18T09:49:05Z
There's a little incompatibility here: mssdk provides these guids in a static library and declares them as extern in headers, but gnu toolchain can't handle this scenario gracefully and would link all guids into executable, hence mingw headers declare guids as static (hidden in C) and doesn't provide static library with them. To use mssdk library and declare guids as extern, write extern extern(C) immutable IID GUID_Button; (without initializer) instead of what currently is in uuid.d
Comment #3 by dfj1esp02 — 2016-10-05T09:28:34Z
Comment #4 by turkeyman — 2016-10-05T14:31:43Z
Turns out the symbols are in druntime (I also couldn't find them in phobos!). druntime also has a uuid.d file, so the same object filename, and the symbols are in there. It seems that druntime and phobos are aggregated into one lib? Weird, but okay... Anyway... I'm not entirely sure these symbols should be in druntime. Why are they there? Why can't users just link the usual libs that supple them? Those libs are now mutually exclusive with phobos, and that's a big problem.
Comment #5 by code — 2016-10-20T12:49:22Z
(In reply to Manu from comment #4) It's probably just a mistake from adding the Windows headers.
Comment #6 by turkeyman — 2016-10-20T12:52:11Z
Okay... so, extern to them and remove the definitions in druntime?
Comment #7 by temtaime — 2017-06-25T21:04:11Z
Yes, do it
Comment #8 by dlang-bugzilla — 2017-06-26T10:30:26Z
Why not just remove the export or extern(C) annotations in core.sys.windows.uuid?
Comment #9 by github-bugzilla — 2018-01-28T16:33:12Z
Commits pushed to master at https://github.com/dlang/druntime https://github.com/dlang/druntime/commit/f9e92a011953bf4fef0e4ef34e898ba14796b93d fix issue 15482 - new uuid.d forbids to link statically with other libraries remove "export extern (C)" from IIDs to not conflict with uuid.lib from the platform SDK https://github.com/dlang/druntime/commit/f2f3f240267376b53f5c72a5a8141139086a3390 Merge pull request #2063 from rainers/issue15482 fix issue 15482 - new uuid.d forbids to link statically with other libs