473,378 Members | 1,420 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Linking problem - bug? please help.

Hi all, sometime I posted a problem in here where I was
getting the following error from the linker in VS C++ 2003.

Linking...
GCClass.obj : error LNK2022: metadata operation failed
(80131188) : Inconsistent field declarations in duplicated
types (types: GCClass; fields: m_blah): (0x04000001).
LINK : fatal error LNK1215: metadata operation failed
(80131130) :

At the time I was unable to produce a simple test case and
due to time constraints I had to leave the problem. I had
another go at it today and was able to produce a simple
test case. The code follows:

namespace itga
{

template<typename Type>
class dog
{
public:
class blah {};
};

}

public __gc class GCClass
{
itga::dog<int>::blah* m_blah;
};

If I attempt to instantiate GCClass as follows I get the
error above.

GCClass* g = new GCClass;

There are two things I can do to get rid of the error:

1. put the dog class outside the itga namespace.
2. not make the dog class a template.

Neither of these is possible nor desirable as I'm just
trying to wrap a heap of existing C++ code in .NET
wrappers and as far as I am concerned this seems perfectly
legal to me.

Does anyone have any idea what is going on here?

thanks.

Gary.
Nov 16 '05 #1
4 2996
Gary Hughes wrote:
Hi all, sometime I posted a problem in here where I was
getting the following error from the linker in VS C++ 2003.

Linking...
GCClass.obj : error LNK2022: metadata operation failed
(80131188) : Inconsistent field declarations in duplicated
types (types: GCClass; fields: m_blah): (0x04000001).
LINK : fatal error LNK1215: metadata operation failed
(80131130) :

At the time I was unable to produce a simple test case and
due to time constraints I had to leave the problem. I had
another go at it today and was able to produce a simple
test case. The code follows:

namespace itga
{

template<typename Type>
class dog
{
public:
class blah {};
};

}

public __gc class GCClass
{
itga::dog<int>::blah* m_blah;
};

If I attempt to instantiate GCClass as follows I get the
error above.

GCClass* g = new GCClass;

There are two things I can do to get rid of the error:

1. put the dog class outside the itga namespace.
2. not make the dog class a template.

Neither of these is possible nor desirable as I'm just
trying to wrap a heap of existing C++ code in .NET
wrappers and as far as I am concerned this seems perfectly
legal to me.

Does anyone have any idea what is going on here?


There's more to it than what you posted. Taking your sample code above and
making it into a complete program:

#using <mscorlib.dll>

namespace itga
{

template<typename Type>
class dog
{
public:
class blah {};
};

}

public __gc class GCClass
{
itga::dog<int>::blah* m_blah;
};

int main()
{
GCClass* g = new GCClass;
}

compiing with cl -clr compiles and links without incident. Can you post a
complete example along with compiler command-line options?

-cd
Nov 16 '05 #2
-----Original Message-----
Gary Hughes wrote:
Hi all, sometime I posted a problem in here where I was
getting the following error from the linker in VS C++ 2003.
Linking...
GCClass.obj : error LNK2022: metadata operation failed
(80131188) : Inconsistent field declarations in duplicated types (types: GCClass; fields: m_blah): (0x04000001).
LINK : fatal error LNK1215: metadata operation failed
(80131130) :

At the time I was unable to produce a simple test case and due to time constraints I had to leave the problem. I had another go at it today and was able to produce a simple
test case. The code follows:

namespace itga
{

template<typename Type>
class dog
{
public:
class blah {};
};

}

public __gc class GCClass
{
itga::dog<int>::blah* m_blah;
};

If I attempt to instantiate GCClass as follows I get the
error above.

GCClass* g = new GCClass;

There are two things I can do to get rid of the error:

1. put the dog class outside the itga namespace.
2. not make the dog class a template.

Neither of these is possible nor desirable as I'm just
trying to wrap a heap of existing C++ code in .NET
wrappers and as far as I am concerned this seems perfectly legal to me.

Does anyone have any idea what is going on here?
There's more to it than what you posted. Taking your

sample code above andmaking it into a complete program:

#using <mscorlib.dll>

namespace itga
{

template<typename Type>
class dog
{
public:
class blah {};
};

}

public __gc class GCClass
{
itga::dog<int>::blah* m_blah;
};

int main()
{
GCClass* g = new GCClass;
}

compiing with cl -clr compiles and links without incident. Can you post acomplete example along with compiler command-line options?

-cd
.


Sorry Carl, one thing I did not mention main() needs to be
in a separate file the class #included. I can send you a
complete project if you like. If the whole thing is in a
single cpp file it works correctly as you found.

Gary.
Nov 16 '05 #3
Gary Hughes wrote:
Sorry Carl, one thing I did not mention main() needs to be
in a separate file the class #included. I can send you a
complete project if you like. If the whole thing is in a
single cpp file it works correctly as you found.


ZIP it up and post it here, or you can email to me - your choice. Do the
obvious things to my reply-to address to get a real email address.

-cd
Nov 16 '05 #4
i work with c++ team, i created two files, one header file with your class
and one cpp which #Includes the header, but we cannot repro it.
It will be great if you can send the repro project to my email address.
(remove the online ,from my address) or post a better repro. We would like
to understand as to why this doesn't work.
Mahesh
--------------------
Content-Class: urn:content-classes:message
From: "Gary Hughes" <ge*@itga.com.au.NOSPAM>
Sender: "Gary Hughes" <ge*@itga.com.au.NOSPAM>
References: <07****************************@phx.gbl> <OU**************@TK2MSFTNGP11.phx.gbl>Subject: Re: Linking problem - bug? please help.
Date: Sun, 26 Oct 2003 19:27:11 -0800
Lines: 103
Message-ID: <04****************************@phx.gbl>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
Thread-Index: AcOcOjW1YYj2fjzUSJeDNUBJ8gfyXA==
Newsgroups: microsoft.public.dotnet.languages.vc
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vc:29763
NNTP-Posting-Host: TK2MSFTNGXA11 10.40.1.163
X-Tomcat-NG: microsoft.public.dotnet.languages.vc

-----Original Message-----
Gary Hughes wrote:
Hi all, sometime I posted a problem in here where I was
getting the following error from the linker in VS C++2003.
Linking...
GCClass.obj : error LNK2022: metadata operation failed
(80131188) : Inconsistent field declarations induplicated types (types: GCClass; fields: m_blah): (0x04000001).
LINK : fatal error LNK1215: metadata operation failed
(80131130) :

At the time I was unable to produce a simple test caseand due to time constraints I had to leave the problem. Ihad another go at it today and was able to produce a simple
test case. The code follows:

namespace itga
{

template<typename Type>
class dog
{
public:
class blah {};
};

}

public __gc class GCClass
{
itga::dog<int>::blah* m_blah;
};

If I attempt to instantiate GCClass as follows I get the
error above.

GCClass* g = new GCClass;

There are two things I can do to get rid of the error:

1. put the dog class outside the itga namespace.
2. not make the dog class a template.

Neither of these is possible nor desirable as I'm just
trying to wrap a heap of existing C++ code in .NET
wrappers and as far as I am concerned this seemsperfectly legal to me.

Does anyone have any idea what is going on here?


There's more to it than what you posted. Taking your

sample code above and
making it into a complete program:

#using <mscorlib.dll>

namespace itga
{

template<typename Type>
class dog
{
public:
class blah {};
};

}

public __gc class GCClass
{
itga::dog<int>::blah* m_blah;
};

int main()
{
GCClass* g = new GCClass;
}

compiing with cl -clr compiles and links without

incident. Can you post a
complete example along with compiler command-line options?

-cd
.


Sorry Carl, one thing I did not mention main() needs to be
in a separate file the class #included. I can send you a
complete project if you like. If the whole thing is in a
single cpp file it works correctly as you found.

Gary.


Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Rudy | last post by:
I am desperately seeking some help with a program that was supposed to have been completed last night. I have only been working with PHP for a week. I have tried and tried and tried, but I am...
0
by: gasturbtec | last post by:
please help im new at access programming and i just got this project dropped in my lap because the old programmer quit. i've been doing ok so far but now i need to add code to an existing database...
1
by: bab | last post by:
i need help linking my relational data base. some one help me please. i can link a one to one relationship but i cant link a one to many for some unknown reason. can some one please tell me how to...
2
by: | last post by:
Help! I'm new to c++, and am breaking my teeth on MS Visual C++ (bundled within Visual Studio .NET 2003). Am trying to link simple c++ code to fortran dlls created in Compaq Visual Fortran (v6.1)....
7
by: Hal Vaughan | last post by:
I have a problem with port forwarding and I have been working on it for over 2 weeks with no luck. I have found C programs that almost work and Java programs that almost work, but nothing that...
1
by: buchalino | last post by:
Hi Guys, Please can someone help me, I am having a linking problem . I am writing a socket program, the problem is just the linking . I am using VC++ In the process of the problem, I...
1
by: srikar | last post by:
what is the difference between static linking & dynamic linking, what are the advantages of each? How to perform static linking & Dynamic linking by using gcc -o liniking will be done , but...
0
by: xieml2007 | last post by:
Dear Madam or Sir, I encountered one problem which is quite similiar to the discussions launched at the web site: http://www.thescripts.com/forum/thread280324.html
0
NeoPa
by: NeoPa | last post by:
If anyone can help with a problem linking across to a table in a database on a SQL 2000 server, then please visit Linking from Access over in SQL Server. I'm locking this so that any and all...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.