Correctly importing uuid
Hi all, I'm working on dlls/wmp and I have added code that now requires GUID_NULL. Instead of duplicating its definition I was trying to add "uuid" to IMPORTS section of Makefile. When I do that I get get multiple definitions of various GUIDs. To fix that I have removed #include "initguid.h" from wmp_main.c . That fixes multiple definitions however this brings undefined references such as: wine/dlls/wmp/oleobj.c:255: undefined reference to `IID_IWMPCore' x86_64-pc-linux-gnu/bin/ld: oleobj.o: relocation R_386_GOTOFF against undefined hidden symbol `IID_IWMPCore' can not be used when making a shared object now. It is unclear to me what is the right way to fix this issue. Can someone shed some light on a proper way to do that? (I can solve that by duplicating GUID_NULL definition but I was said that its not needed) Thanks!
Hi Anton, On 2/16/18 7:35 AM, Anton Romanov wrote:
Hi all,
I'm working on dlls/wmp and I have added code that now requires GUID_NULL. Instead of duplicating its definition I was trying to add "uuid" to IMPORTS section of Makefile. When I do that I get get multiple definitions of various GUIDs. To fix that I have removed #include "initguid.h" from wmp_main.c . That fixes multiple definitions however this brings undefined references such as:
wine/dlls/wmp/oleobj.c:255: undefined reference to `IID_IWMPCore' x86_64-pc-linux-gnu/bin/ld: oleobj.o: relocation R_386_GOTOFF against undefined hidden symbol `IID_IWMPCore' can not be used when making a shared object
now. It is unclear to me what is the right way to fix this issue. Can someone shed some light on a proper way to do that? (I can solve that by duplicating GUID_NULL definition but I was said that its not needed)
There are two main ways of importing uuids. First one, more common, is to add uuid (or other similar library) to IMPORTS in Makefile, which imports uuid from a static lib. This is usually preferred. However, this does not work nice in wmp.dll case because IID_IWMPCore (and other WMP uuids) are not present in any such lib. In such cases we need to use the second way. Note that uuids are usually defined using DEFINE_GUID in headers, see guiddef.h for the macro. It expands to |extern const GUID| unless DEFINE_GUID is defined. If it's defined, full declaration is included. In wmp_main.c we include initguid.h, which defines DEFINE_GUID macro. It means that we will have uuids declared for all headers included in wmp_main.c. That said, if you need more uuids in wmp.dll, just include a file containing their declarations in wmp_main.c. Thanks, Jacek
Am 16.02.2018 um 11:09 schrieb Jacek Caban <jacek(a)codeweavers.com>:
In such cases we need to use the second way. Note that uuids are usually defined using DEFINE_GUID in headers, see guiddef.h for the macro. It expands to |extern const GUID| unless DEFINE_GUID is defined. If it's defined, full declaration is included. In wmp_main.c we include initguid.h, which defines DEFINE_GUID macro. It means that we will have uuids declared for all headers included in wmp_main.c. Wouldn't it be possible to include public headers that have GUIDs from uuid.lib, then include initguid.h, and then include headers that define WMP guids (or define the WMP GUIDs manually)? That should import guids that work with uuid.lib from there and define the rest.
Of course the beauty of a half-way approach is always questionable, so not sure if that's better than just using DEFINE_GUID for everything.
On 02/16/2018 12:27 PM, Stefan Dösinger wrote:
Am 16.02.2018 um 11:09 schrieb Jacek Caban <jacek(a)codeweavers.com <mailto:jacek(a)codeweavers.com>>:
In such cases we need to use the second way. Note that uuids are usually defined using DEFINE_GUID in headers, see guiddef.h for the macro. It expands to |extern const GUID| unless DEFINE_GUID is defined. If it's defined, full declaration is included. In wmp_main.c we include initguid.h, which defines DEFINE_GUID macro. It means that we will have uuids declared for all headers included in wmp_main.c. Wouldn't it be possible to include public headers that have GUIDs from uuid.lib, then include initguid.h, and then include headers that define WMP guids (or define the WMP GUIDs manually)? That should import guids that work with uuid.lib from there and define the rest.
Of course the beauty of a half-way approach is always questionable, so not sure if that's better than just using DEFINE_GUID for everything.
Sure, that would work as well. The downside is that then we depend on includes hierarchy - if we ever need to change includes in headers, we need to take that into account in non-intuitive places. It's not a big deal, so I think the solution is fine. Thanks, Jacek
In such cases we need to use the second way. Note that uuids are usually defined using DEFINE_GUID in headers, see guiddef.h for the macro. It expands to |extern const GUID| unless DEFINE_GUID is defined. If it's defined, full declaration is included. In wmp_main.c we include initguid.h, which defines DEFINE_GUID macro. It means that we will have uuids declared for all headers included in wmp_main.c.
Wouldn't it be possible to include public headers that have GUIDs from uuid.lib, then include initguid.h, and then include headers that define WMP guids (or define the WMP GUIDs manually)? That should import guids that work with uuid.lib from there and define the rest.
Of course the beauty of a half-way approach is always questionable, so not sure if that's better than just using DEFINE_GUID for everything.
Sure, that would work as well. The downside is that then we depend on includes hierarchy - if we ever need to change includes in headers, we need to take that into account in non-intuitive places. It's not a big deal, so I think the solution is fine. So, I'm still confused - what do I need to include to have GUID_NULL without linking to uuid and without declaring it myself?
Thanks, Anton.
On 02/16/2018 05:59 PM, Anton Romanov wrote:
In such cases we need to use the second way. Note that uuids are usually defined using DEFINE_GUID in headers, see guiddef.h for the macro. It expands to |extern const GUID| unless DEFINE_GUID is defined. If it's defined, full declaration is included. In wmp_main.c we include initguid.h, which defines DEFINE_GUID macro. It means that we will have uuids declared for all headers included in wmp_main.c.
Wouldn't it be possible to include public headers that have GUIDs from uuid.lib, then include initguid.h, and then include headers that define WMP guids (or define the WMP GUIDs manually)? That should import guids that work with uuid.lib from there and define the rest.
Of course the beauty of a half-way approach is always questionable, so not sure if that's better than just using DEFINE_GUID for everything.
Sure, that would work as well. The downside is that then we depend on includes hierarchy - if we ever need to change includes in headers, we need to take that into account in non-intuitive places. It's not a big deal, so I think the solution is fine. So, I'm still confused - what do I need to include to have GUID_NULL without linking to uuid and without declaring it myself?
Declaring it yourself in wmp_main.c is fine. Just please don't add such things when you don't need it. I commented on it because you added it in a patch that didn't need it. Jacek
On Fri, Feb 16, 2018 at 9:04 AM, Jacek Caban <jacek(a)codeweavers.com> wrote:
On 02/16/2018 05:59 PM, Anton Romanov wrote:
In such cases we need to use the second way. Note that uuids are usually defined using DEFINE_GUID in headers, see guiddef.h for the macro. It expands to |extern const GUID| unless DEFINE_GUID is defined. If it's defined, full declaration is included. In wmp_main.c we include initguid.h, which defines DEFINE_GUID macro. It means that we will have uuids declared for all headers included in wmp_main.c.
Wouldn't it be possible to include public headers that have GUIDs from uuid.lib, then include initguid.h, and then include headers that define WMP guids (or define the WMP GUIDs manually)? That should import guids that work with uuid.lib from there and define the rest.
Of course the beauty of a half-way approach is always questionable, so not sure if that's better than just using DEFINE_GUID for everything.
Sure, that would work as well. The downside is that then we depend on includes hierarchy - if we ever need to change includes in headers, we need to take that into account in non-intuitive places. It's not a big deal, so I think the solution is fine. So, I'm still confused - what do I need to include to have GUID_NULL without linking to uuid and without declaring it myself?
Declaring it yourself in wmp_main.c is fine. Just please don't add such things when you don't need it. I commented on it because you added it in a patch that didn't need it.
Oh, I see, thanks!
participants (3)
-
Anton Romanov -
Jacek Caban -
Stefan Dösinger