LNK1179 error 
Author Message
 LNK1179 error

Hello,

I have two dll (first.dll, second.dll) that implement
the same interface IMat. When I want to use them

#import "first.dll" named_guids
#import "second.dll" named_guids

  FirstLib::IMatPtr pA=NULL;
  pA.CreateInstance(FirstLib::CLSID_First);
  pA.CreateInstance(SecondLib::CLSID_Second);

I get LNK1179 link error on duplicate comdat "_IID_IMat".

I know how to get rid of it, simply

#import "first.dll" named_guids
#import "second.dll"

  FirstLib::IMatPtr pA=NULL;
  pA.CreateInstance(FirstLib::CLSID_First);
  pA.CreateInstance("{3c89291b-9fc4-424f-bbd9-10810405392f}");

nevertheless I would like to use named_guids. So my questions are
1.) Is there any option for #import that prevents creating IID_IMat and
just creates CLSID_Second?
2.) Why this error appeared at all? I did not ask for IID_IMat in global
namespace. I have it twice, but in its own namespaces, there should not be
any problem. This is what are namespaces for, isn't it?

Any insight will be appreciated.

Best regards,

Ondrej Pokluda



Mon, 20 Sep 2004 15:05:50 GMT  
 LNK1179 error
rename_namespace option (of #import statement) will probably fit

Quote:

> Hello,

> I have two dll (first.dll, second.dll) that implement
> the same interface IMat. When I want to use them

> #import "first.dll" named_guids
> #import "second.dll" named_guids

>   FirstLib::IMatPtr pA=NULL;
>   pA.CreateInstance(FirstLib::CLSID_First);
>   pA.CreateInstance(SecondLib::CLSID_Second);

> I get LNK1179 link error on duplicate comdat "_IID_IMat".

> I know how to get rid of it, simply

> #import "first.dll" named_guids
> #import "second.dll"

>   FirstLib::IMatPtr pA=NULL;
>   pA.CreateInstance(FirstLib::CLSID_First);
>   pA.CreateInstance("{3c89291b-9fc4-424f-bbd9-10810405392f}");

> nevertheless I would like to use named_guids. So my questions are
> 1.) Is there any option for #import that prevents creating IID_IMat and
> just creates CLSID_Second?
> 2.) Why this error appeared at all? I did not ask for IID_IMat in global
> namespace. I have it twice, but in its own namespaces, there should not be
> any problem. This is what are namespaces for, isn't it?

> Any insight will be appreciated.

> Best regards,

> Ondrej Pokluda

--

Whitestein Technologies | www.whitestein.com
Panenska 28 | SK-81103 Bratislava | Slovak Republic
Tel +421(2)5443-5502 | Fax +421(2)5443-5512


Mon, 20 Sep 2004 17:47:27 GMT  
 LNK1179 error


Fri, 19 Jun 1992 00:00:00 GMT  
 LNK1179 error

Quote:
> rename_namespace option (of #import statement) will probably fit

Thank you for the answer.

It does not help. Both dlls have proper namespaces, problem is
with compilation of file that uses it. Everything is compiled in its
namespace FirstLib, SecondLib, but ...
In automagically generated second.tlh there is something like

namespace SecondLib {
...
extern "C" const GUID __declspec(selectany) LIBID_SecondLib =
    {0x95ae4e01,0x02bf,0x4843,{0x8c,0xb2,0xfc,0x4c,0xfb,0xa0,0xa8,0xcb}};
extern "C" const GUID __declspec(selectany) CLSID_Second =
    {0x3c89291b,0x9fc4,0x424f,{0xbb,0xd9,0x10,0x81,0x04,0x05,0x39,0x2f}};
extern "C" const GUID __declspec(selectany) IID_IMat =
    {0x938f28fc,0xf529,0x4951,{0x95,0xcb,0x8b,0x3d,0xda,0x59,0xbb,0xcf}};
...

Quote:
} // namespace SecondLib

similar for first.tlh Problem is obviously in mixing namespace{ } and
extern "C" linkage. Hence I have twice IID_IMat, first as
FirstLib::IID_IMat,
second as SecondLib::IID_IMat, both compiled as _IID_IMat.
So I know perfectly what caused the problem, I have half-dozen of solutions,
I want to know what is the "optimal one". Most likely get rid of named_guids
I guess.

Remarks, questions:
- Is it only my idea that using extern "C" inside namespace{} is a Bad
Thing?
- Is there way to say to #import directive "generate named_guids except
of IID_IMat"? I do not thing so, exclude does not work.

Regards,

Ondrej Pokluda



Mon, 20 Sep 2004 20:19:33 GMT  
 LNK1179 error


Fri, 19 Jun 1992 00:00:00 GMT  
 LNK1179 error
The best way out of such situation is to put shared declarations (like
your IMat interface) into a separate IDL file and compile it into a
separate TLB. The first.idl and second.idl should then use import
"shared.idl" outside library block, and importlib("shared.tlb") inside
library block. When you later #import either TLB in your client code,
the compiler will follow the reference to shared.tlb, generate
shared.tlh and shared.tli and #include them in first.tlh and second.tlh
as appropriate.
--
With best wishes,
    Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken


Quote:
> Hello,

> I have two dll (first.dll, second.dll) that implement
> the same interface IMat. When I want to use them

> #import "first.dll" named_guids
> #import "second.dll" named_guids

>   FirstLib::IMatPtr pA=NULL;
>   pA.CreateInstance(FirstLib::CLSID_First);
>   pA.CreateInstance(SecondLib::CLSID_Second);

> I get LNK1179 link error on duplicate comdat "_IID_IMat".

> I know how to get rid of it, simply

> #import "first.dll" named_guids
> #import "second.dll"

>   FirstLib::IMatPtr pA=NULL;
>   pA.CreateInstance(FirstLib::CLSID_First);
>   pA.CreateInstance("{3c89291b-9fc4-424f-bbd9-10810405392f}");

> nevertheless I would like to use named_guids. So my questions are
> 1.) Is there any option for #import that prevents creating IID_IMat
and
> just creates CLSID_Second?
> 2.) Why this error appeared at all? I did not ask for IID_IMat in
global
> namespace. I have it twice, but in its own namespaces, there should
not be
> any problem. This is what are namespaces for, isn't it?

> Any insight will be appreciated.

> Best regards,

> Ondrej Pokluda



Mon, 20 Sep 2004 23:59:49 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. LNK1179 error

2. LNK1179 error problem

3. fatal error LNK1179: invalid or corrupt file

4. Linker error LNK1179 -- what's a COMDAT?

5. Linker error LNK1179 -- what's a COMDAT?

6. Linker error LNK1179 -- what's a COMDAT?

7. fatal error LNK1179

8. LNK1179 : duplicate COMDAT

9. LNK1179 - Compiler bug?

10. LNK1179 invalid or corrupt comdat HELP !!!

11. LNK1179

12. error, error, error !!!

 

 
Powered by phpBB® Forum Software