托管C ++链接错误 [英] managed C++ link error

查看:73
本文介绍了托管C ++链接错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在尝试链接一个

托管的C ++ dll时遇到以下错误。谷歌找不到这些

错误的参考。有人可以帮忙吗?我已经包含了

类定义导致下面的错误。


一切都编译得很好并且所有类型都被定义了,它

出现模板类型

itga :: order_collection :: iterator导致麻烦。


加里。


编译...

OrderEnumerator.cpp

链接...

创建库z:\bin\ITGAdotnetd.lib和对象

z:\ bin \ITGAdotnetd.exp

OrderEnumerator.obj:错误LNK2022:元数据操作

失败(80131187):不一致方法声明

重复类型(类型:OrderEnumerator;方法:.ctor):

(0x06000001)。

OrderEnumerator.obj:错误LNK2022 :元数据操作

失败(80131188):

重复类型中的不一致字段声明(类型:OrderEnumerator;字段:

m_current):( 0x04000013) )。

链接:致命错误LNK1215:元数据操作失败

(80131130):


构建日志已保存

atfile:// z:\ src \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ b ------------------------------------------------- --------


public __gc class OrderEnumerator:public

System :: Collections :: IEnumerator

{

public:


OrderEnumerator(const itga :: order_collection_ptr&

collection,

const

itga :: order_collection :: iterator&位置);


~OrderEnumerator();


__property System :: Object * get_Current();

bool MoveNext();

void重置();


私人:


itga :: order_collection_ptr * m_orders ;

itga :: order_collection :: iterator * m_current;


};

解决方案

之前我已经有了这个,并且永远无法缩小确切的原因,但

似乎与#using<>的顺序有关。语句(特别是当

你包括头文件时也有#using<>语句)。制作

如果你不需要或者根本不需要它,那么你肯定不会两次#not $

不需要它。


Brian


" Gary Hughes" < ge*@itga.com.au>在消息中写道

news:08 **************************** @ phx.gbl ... < blockquote class =post_quotes>我在尝试链接一个
托管的C ++ dll时遇到以下错误。谷歌我找不到这些
错误的任何参考。有人可以帮忙吗?我已经包含了导致下面错误的
类定义。

所有编译都很好并且所有类型都已定义,它似乎是模板类型
itga :: order_collection :: iterator引起了麻烦。

Gary。

编译......
OrderEnumerator.cpp
链接......
创建库z:\bin\ITGAdotnetd.lib和object
z:\bin\ITGAdotnetd.exp
OrderEnumerator.obj:错误LNK2022:元数据操作
失败(80131187 ):
重复类型中的方法声明不一致(类型:OrderEnumerator;方法:.ctor):
(0x06000001)。
OrderEnumerator.obj:错误LNK2022:元数据操作失败( 80131188):重复类型中的字段声明不一致(类型:OrderEnumerator;字段:
m_current):( 0x04000013)。
LINK:致命错误LNK1215:元数据操作失败
(80131130 ):

构建日志已保存在" file:// z:\ rc\desk\client\dotnet\Debug \ BuildLog.htm"
ITGAdotnet - 3个错误,0个警告

------ -------------------------------------------------- -

public __gc class OrderEnumerator:public
System :: Collections :: IEnumerator
{
公开:

OrderEnumerator(const itga: :order_collection_ptr&
集合,
const
itga :: order_collection :: iterator&位置);

~OrderEnumerator();
__property System :: Object * get_Current();
bool MoveNext();
void重置( );

私人:

itga :: order_collection_ptr * m_orders;
itga :: order_collection :: iterator * m_current;

} ;



感谢线索Brian,但没有快乐。我已经删除了

的东西,以便我有四个文件。


OrderEnumerator.h

OrderEnumerator.cpp

OrderCollection.h

OrderCollection.cpp


这些文件不包含在任何其他项目文件中。

添加#include" OrderEnumerator.h" to OrderCollection.cpp

导致错误。我实际上并没有使用来自OrderEnumerator.h的任何东西。我只需要包含该文件。

这些文件中没有#using语句。我通过stdafx.h包含了

itga :: stuff的定义,我已经尝试将b / b
直接包含在标题和cpp中

文件也有问题。

此外,如果我注释掉使用

itga :: order_collection :: iterator那么问题就出现了问题

远。一切都编译得很好,我在其他地方使用

itga :: order_collection :: iterator(在一个普通的cpp

库和一个COM包装器库中)没有任何问题

在solaris上使用VC ++和G ++。


所有无用的cpp文件都包含警卫和

托管头文件都有#pragma一次。


看来VC ++正在生成某种符号

信息并弄错了,可能涉及转发

声明?


顺便说一下,我正在使用visual studio 2003.


有人有任何线索吗?

-----原始消息-----
我之前已经有了这个,并且从来没有能够缩小
的确切原因,但似乎与顺序有关使用&#LT;>
语句(特别是当你包含头文件时也包含#using<>
语句)。如果你不需要
,或者根本不需要
,那么你就不会做任何事情。

Brian

加里休斯 < ge*@itga.com.au>在消息中写道
新闻:08 **************************** @ phx.gbl ...

我在尝试链接
a托管C ++ dll时遇到以下错误。谷歌我找不到这些
错误的任何参考。有人可以帮忙吗?我已经包含了导致下面错误的
类定义。

所有编译都很好并且所有类型都已定义,
看起来模板类型
itga :: order_collection :: iterator引起了麻烦。

Gary。

编译......
OrderEnumerator.cpp
链接......
创建库z:\bin\ITGAdotnetd.lib和object
z:\bin\ITGAdotnetd.exp
OrderEnumerator.obj:错误LNK2022:元数据操作
失败(80131187 ):
重复类型中的方法声明不一致(类型:OrderEnumerator;
方法:.ctor):( 0x06000001)。
OrderEnumerator.obj:错误LNK2022:元数据操作失败( 80131188):重复类型中的字段声明不一致(类型:OrderEnumerator;字段:
m_current):( 0x04000013)。
LINK:致命错误LNK1215:元数据操作失败
(80131130 ):

构建日志已保存在" file:// z:\ src中\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ -------------------------------------------------
-
public __gc class OrderEnumerator:public
System :: Collections :: IEnumerator
{
公开:

OrderEnumerator(const itga :: order_collection_ptr&
集合,
const
itga :: order_collection :: iterator&位置);

~OrderEnumerator();
__property System :: Object * get_Current();
bool MoveNext();
void重置( );

私人:

itga :: order_collection_ptr * m_orders;
itga :: order_collection :: iterator * m_current;

} ;





此外,如果我只是简单地放入所有代码

OrderEnumerator。[h | cpp]进入OrderCollection.cpp它

编译和链接没有问题。

--- - 原创讯息-----
感谢布莱恩的线索,但没有快乐。我已经删除了一些东西,以便我有四个文件。

OrderEnumerator.h
OrderEnumerator.cpp
OrderCollection.h
OrderCollection.cpp

这些文件不包含在任何其他项目文件中。
添加#include" OrderEnumerator.h" to
OrderCollection.cppcauses有问题的错误。我实际上并没有使用来自OrderEnumerator.h的任何东西我只是包含了这个文件。
这些文件中没有#using语句。我通过stdafx.h包含了itga :: stuff的定义,我已经尝试将它们直接包含在标题和cpp
文件中。

此外,如果我注释掉使用
itga :: order_collection :: iterator,那么问题就会消失。一切都编译得很好,我在其他地方(在一个简单的
cpplibrary和一个COM包装器库中)使用
itga :: order_collection :: iterator,在solaris上使用VC ++和G ++都没有问题。 br />
所有无用的cpp文件都包含警卫和
托管头文件都有#pragma一次。

看来VC ++正在生成某种符号
信息和错误,可能涉及到前面的声明?

顺便说一下,我正在使用visual studio 2003.

有没有人有任何线索?

-----原始消息-----
我之前已经有了这个并且永远无法缩小确切原因,但是

似乎与#using<>


语句的顺序有关(特别是当

你包含的头文件时##使用<>


语句)。 make

如果你不需要


,那么确保你没有#using任何东西,如果你

don'不需要它。

Brian

Gary Hughes < ge*@itga.com.au>在消息中写道
新闻:08 **************************** @ phx.gbl ...

我在尝试
linka

托管C ++ dll时遇到以下错误。谷歌我找不到这些
错误的任何参考。有人可以帮忙吗?我已经包含了导致下面错误的
类定义。

所有编译都很好,所有类型都是


定义,

看来模板类型
itga :: order_collection :: iterator导致


麻烦。
Gary。

编译......
OrderEnumerator.cpp
链接......
创建库z:\bin\ITGAdotnetd.lib和对象
z:\bin\ITGAdotnetd.exp
OrderEnumerator.obj:错误LNK2022:元数据操作失败(80131187):
重复类型中的方法声明不一致(类型:OrderEnumerator;

方法:.ctor):( 0x06000001)。
OrderEnumerator.obj:错误LNK2022:元数据操作失败(80131188):重复类型中的字段声明不一致(类型:OrderEnumerator;字段:
m_current):( 0x04000013)。
LINK:致命错误LNK1215:元数据操作失败
(80131130):

构建日志已保存

atfile:// z:\src\desk\client\dotnet \Debug \ BuildLog.htm" ITGAdotnet - 3个错误,0个警告

----------------------------- --------------------------


-
public __gc class OrderEnumerator:public
System :: Collections :: IEnumerator
{
公开:

OrderEnumerator(const itga :: order_collection_ptr&
集合,
const
itga :: order_collection :: iterator& position);

~OrderEnumerator();
__property System :: Object * get_Current();
bool MoveNext();
void重置();

私人:

itga :: order_collection_ptr * m_orders;
itga :: order_collection :: iterator * m_current;

};






I''m getting the following error when attempting to link a
managed C++ dll. I can''t find any reference to these
errors with google. Can anyone help? I''ve included the
class definition causing the errors below.

Everything compiles fine and all the types are defined, it
appears that the template type
itga::order_collection::iterator is causing the trouble.

Gary.

Compiling...
OrderEnumerator.cpp
Linking...
Creating library z:\bin\ITGAdotnetd.lib and object
z:\bin\ITGAdotnetd.exp
OrderEnumerator.obj : error LNK2022: metadata operation
failed (80131187) : Inconsistent method declarations in
duplicated types (types: OrderEnumerator; methods: .ctor):
(0x06000001).
OrderEnumerator.obj : error LNK2022: metadata operation
failed (80131188) : Inconsistent field declarations in
duplicated types (types: OrderEnumerator; fields:
m_current): (0x04000013).
LINK : fatal error LNK1215: metadata operation failed
(80131130) :

Build log was saved
at "file://z:\src\desk\client\dotnet\Debug\BuildLog.htm"
ITGAdotnet - 3 error(s), 0 warning(s)

---------------------------------------------------------

public __gc class OrderEnumerator : public
System::Collections::IEnumerator
{
public:

OrderEnumerator(const itga::order_collection_ptr&
collection,
const
itga::order_collection::iterator& position);

~OrderEnumerator();

__property System::Object* get_Current();
bool MoveNext();
void Reset();

private:

itga::order_collection_ptr* m_orders;
itga::order_collection::iterator* m_current;

};

解决方案

I''ve had this before and was never able to narrow down the exact cause, but
is seemed to have to do with the order of #using<> statements (esp. when
you''re including header files that also have #using<> statements). Make
sure you''re not #using anything twice if you don''t need to or at all if you
don''t need it.

Brian

"Gary Hughes" <ge*@itga.com.au> wrote in message
news:08****************************@phx.gbl...

I''m getting the following error when attempting to link a
managed C++ dll. I can''t find any reference to these
errors with google. Can anyone help? I''ve included the
class definition causing the errors below.

Everything compiles fine and all the types are defined, it
appears that the template type
itga::order_collection::iterator is causing the trouble.

Gary.

Compiling...
OrderEnumerator.cpp
Linking...
Creating library z:\bin\ITGAdotnetd.lib and object
z:\bin\ITGAdotnetd.exp
OrderEnumerator.obj : error LNK2022: metadata operation
failed (80131187) : Inconsistent method declarations in
duplicated types (types: OrderEnumerator; methods: .ctor):
(0x06000001).
OrderEnumerator.obj : error LNK2022: metadata operation
failed (80131188) : Inconsistent field declarations in
duplicated types (types: OrderEnumerator; fields:
m_current): (0x04000013).
LINK : fatal error LNK1215: metadata operation failed
(80131130) :

Build log was saved
at "file://z:\src\desk\client\dotnet\Debug\BuildLog.htm"
ITGAdotnet - 3 error(s), 0 warning(s)

---------------------------------------------------------

public __gc class OrderEnumerator : public
System::Collections::IEnumerator
{
public:

OrderEnumerator(const itga::order_collection_ptr&
collection,
const
itga::order_collection::iterator& position);

~OrderEnumerator();

__property System::Object* get_Current();
bool MoveNext();
void Reset();

private:

itga::order_collection_ptr* m_orders;
itga::order_collection::iterator* m_current;

};



Thanks for the clues Brian but no joy. I have stripped
things down so that I have four files.

OrderEnumerator.h
OrderEnumerator.cpp
OrderCollection.h
OrderCollection.cpp

These files are not included in any other project files.
Adding #include "OrderEnumerator.h" to OrderCollection.cpp
causes the error in question. I don''t actually use
anything from OrderEnumerator.h I just include the file.
There are no #using statements in these files. I include
the definitions of the itga:: stuff via stdafx.h, I have
tried including them directly in both the header and cpp
files in question as well.
Furthermore if I comment out the use of
itga::order_collection::iterator then the problem goes
away. Everything compiles fine and I use the
itga::order_collection::iterator elsewhere (in a plain cpp
library and a COM wrapper library) with no problems both
with VC++ and G++ on solaris.

All the unerlying cpp files have include guards and the
managed header files all have #pragma once.

It appears VC++ is generating some kind of symbol
information and getting it wrong, maybe involving forward
declarations?

btw, I''m using visual studio 2003.

Does anyone have any clues?

-----Original Message-----
I''ve had this before and was never able to narrow down the exact cause, butis seemed to have to do with the order of #using<> statements (esp. whenyou''re including header files that also have #using<> statements). Makesure you''re not #using anything twice if you don''t need to or at all if youdon''t need it.

Brian

"Gary Hughes" <ge*@itga.com.au> wrote in message
news:08****************************@phx.gbl...

I''m getting the following error when attempting to link a managed C++ dll. I can''t find any reference to these
errors with google. Can anyone help? I''ve included the
class definition causing the errors below.

Everything compiles fine and all the types are defined, it appears that the template type
itga::order_collection::iterator is causing the trouble.

Gary.

Compiling...
OrderEnumerator.cpp
Linking...
Creating library z:\bin\ITGAdotnetd.lib and object
z:\bin\ITGAdotnetd.exp
OrderEnumerator.obj : error LNK2022: metadata operation
failed (80131187) : Inconsistent method declarations in
duplicated types (types: OrderEnumerator; methods: .ctor): (0x06000001).
OrderEnumerator.obj : error LNK2022: metadata operation
failed (80131188) : Inconsistent field declarations in
duplicated types (types: OrderEnumerator; fields:
m_current): (0x04000013).
LINK : fatal error LNK1215: metadata operation failed
(80131130) :

Build log was saved
at "file://z:\src\desk\client\dotnet\Debug\BuildLog.htm"
ITGAdotnet - 3 error(s), 0 warning(s)

-------------------------------------------------------- -
public __gc class OrderEnumerator : public
System::Collections::IEnumerator
{
public:

OrderEnumerator(const itga::order_collection_ptr&
collection,
const
itga::order_collection::iterator& position);

~OrderEnumerator();

__property System::Object* get_Current();
bool MoveNext();
void Reset();

private:

itga::order_collection_ptr* m_orders;
itga::order_collection::iterator* m_current;

};


.



Furthermore if I simply put all the code from
OrderEnumerator.[h|cpp] into OrderCollection.cpp it
compiles and links without a problem.

-----Original Message-----
Thanks for the clues Brian but no joy. I have stripped
things down so that I have four files.

OrderEnumerator.h
OrderEnumerator.cpp
OrderCollection.h
OrderCollection.cpp

These files are not included in any other project files.
Adding #include "OrderEnumerator.h" to OrderCollection.cppcauses the error in question. I don''t actually use
anything from OrderEnumerator.h I just include the file.
There are no #using statements in these files. I include
the definitions of the itga:: stuff via stdafx.h, I have
tried including them directly in both the header and cpp
files in question as well.
Furthermore if I comment out the use of
itga::order_collection::iterator then the problem goes
away. Everything compiles fine and I use the
itga::order_collection::iterator elsewhere (in a plain cpplibrary and a COM wrapper library) with no problems both
with VC++ and G++ on solaris.

All the unerlying cpp files have include guards and the
managed header files all have #pragma once.

It appears VC++ is generating some kind of symbol
information and getting it wrong, maybe involving forward
declarations?

btw, I''m using visual studio 2003.

Does anyone have any clues?

-----Original Message-----
I''ve had this before and was never able to narrow downthe exact cause, but

is seemed to have to do with the order of #using<>


statements (esp. when

you''re including header files that also have #using<>


statements). Make

sure you''re not #using anything twice if you don''t need


to or at all if you

don''t need it.

Brian

"Gary Hughes" <ge*@itga.com.au> wrote in message
news:08****************************@phx.gbl...

I''m getting the following error when attempting to linka

managed C++ dll. I can''t find any reference to these
errors with google. Can anyone help? I''ve included the
class definition causing the errors below.

Everything compiles fine and all the types are

defined,

it appears that the template type
itga::order_collection::iterator is causing the

trouble.
Gary.

Compiling...
OrderEnumerator.cpp
Linking...
Creating library z:\bin\ITGAdotnetd.lib and object
z:\bin\ITGAdotnetd.exp
OrderEnumerator.obj : error LNK2022: metadata operation
failed (80131187) : Inconsistent method declarations in
duplicated types (types: OrderEnumerator;

methods: .ctor): (0x06000001).
OrderEnumerator.obj : error LNK2022: metadata operation
failed (80131188) : Inconsistent field declarations in
duplicated types (types: OrderEnumerator; fields:
m_current): (0x04000013).
LINK : fatal error LNK1215: metadata operation failed
(80131130) :

Build log was saved
at "file://z:\src\desk\client\dotnet\Debug\BuildLog.htm" ITGAdotnet - 3 error(s), 0 warning(s)

-------------------------------------------------------

--
public __gc class OrderEnumerator : public
System::Collections::IEnumerator
{
public:

OrderEnumerator(const itga::order_collection_ptr&
collection,
const
itga::order_collection::iterator& position);

~OrderEnumerator();

__property System::Object* get_Current();
bool MoveNext();
void Reset();

private:

itga::order_collection_ptr* m_orders;
itga::order_collection::iterator* m_current;

};


.


.



这篇关于托管C ++链接错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆